administrator

$ENV:USERNAME returns the machine name when SCCM runs a script as admin with a non-admin logged in

≡放荡痞女 提交于 2020-01-17 04:49:07
问题 I have a script that needs to run from Software Center when a non-admin is logged in. It needs to copy application data to $ENV:USERNAME\AppData\<dir>\* (among other things) and it needs to run as administrator to work properly. The problem that I've discovered is that when the script is run on a non-admin profile with admin privileges the environment variable $ENV:USERNAME returns the machine name rather than the actual logged in username. Is there a way around this? 回答1: You can either use

Set administrative privileges in C#

十年热恋 提交于 2020-01-17 01:44:10
问题 I have been writing many scripts using WMI and a lot of them only work if I start visual studio with "Run as Administrator". Is there a way to set that programmatically with .Net or other means? Eventually, these scripts will be run as .exes from Unity3D so I need to automate setting these rights before running them. Ideally I'm hoping this can all be done in C#. 回答1: This question was answered in the comments. The only way is to add a manifest file to your project that sets the required

net localgroup administrators equivalent in powershell

亡梦爱人 提交于 2020-01-14 04:37:05
问题 I've configured winrm on all my desktops via GPO, so I can now use the invoke-command cmdlet to run commands locally on remote machines. When I run net localgroup administrators on my local machine this works and gives me what I want. The problem is I cannot do anything with this data. I cannot pipe out the results to a variable so I can lets say remove specific accounts. Is there a built in cmdlet that will let me do the same as net localgroup administrators ? 回答1: While it's possible to run

ShowWindow Function Doesn't Work When Target Application Is Run As Administrator

妖精的绣舞 提交于 2020-01-12 08:51:31
问题 I am writing a program that shows/hides the window of some target application. I was testing it out earlier and noticed something strange. If I run the target application as Administrator (right-click->Properties, "Compatability" tab, "Run this program as administrator") it doesn't work. To demonstrate I wrote a simple GUI app called "TargetApplication" and then I wrote the following code to test showing/hiding this application: class Program { static void Main(string[] args) { IntPtr

Start / Stop a Windows Service from a non-Administrator user account

前提是你 提交于 2020-01-08 11:21:29
问题 I have a WindowsService named, say, BST. And I need to give a non-Administrator user, UserA, the permissions to Start/Stop this particular service. My service runs on a variety of Windows OS, starting from Windows Server 2003 to Windows 7. How can I do this? I Googled and found some stuff about giving permissions using the command [sc sdset], but I am not exactly sure about the parameters. I do not want to set the permissions for a group, but ONLY to a particular user, UserA in this case. 回答1

Self Elevating Script + Execution Policy

喜欢而已 提交于 2020-01-03 02:00:12
问题 I'm trying to use the following code from th question "PowerShell: Running a command as Administrator" to not only self elevate my script to run automatically in an Administrator-level PowerShell, but also for the Administrator-level PowerShell session to be run with an ExecutionPolicy level of RemoteSigned. I'm assuming that I need to use something like -ExecutionPolicy RemoteSigned in $newProcess.Arguments but am completely lost as to if this is the case, and if it is then what the syntax

programmatically run cmd.exe as administrator in vista, C#

点点圈 提交于 2019-12-30 06:39:45
问题 I have a visual studio setup and deployment project. I've added a .cmd script in it. The script would need administrator privileges to run. When user clicks on the setup.exe, UAC prompts the user for Admin permissions. So I assumed that all processes created and called within setup.exe will run in admin capacity. So I made the setup call my console application which contains the following code. ProcessStartInfo p1 = new ProcessStartInfo(); p1.UseShellExecute = true; p1.Verb = "runas"; p1

programmatically run cmd.exe as administrator in vista, C#

三世轮回 提交于 2019-12-30 06:39:13
问题 I have a visual studio setup and deployment project. I've added a .cmd script in it. The script would need administrator privileges to run. When user clicks on the setup.exe, UAC prompts the user for Admin permissions. So I assumed that all processes created and called within setup.exe will run in admin capacity. So I made the setup call my console application which contains the following code. ProcessStartInfo p1 = new ProcessStartInfo(); p1.UseShellExecute = true; p1.Verb = "runas"; p1

saving permissions as json in Administrator for this error-> Cannot JSON_decode permissions [Admin]

穿精又带淫゛_ 提交于 2019-12-24 00:34:54
问题 I am using Administrator (frozennode) with Sentry . for permission part when I want to create new group I dont know how should I save the text "user.update" like {"user.update":1} . I have to .because sentry's methods work just with json data. but when I import different kind of permissions or groups how do this? how should I change the Administrator save() method to force it do that just for "permission" field? the save() function -> http://laravel.io/bin/qkr76 thanks for your time 来源: https

VB6 is application running as administrator

一笑奈何 提交于 2019-12-23 13:05:00
问题 Is there any way of finding out if the application is running as administrator? If this involves a COM call, I'm not really fussed, anything that works! 回答1: IsUserAnAdmin is an easy call and seems perfectly reliable for use in VB6 programs. It seems to work fine even in Win8. Note that it reports whether the process is running with admin rights, not whether the user is in the Administrators group. Declaring it this way it should work all the way back to Windows 2000: Private Declare Function