Is there a way to run regedit on a bunch of remote computers without UAC popping up on Windows10? the /s on command line is not working on my windows 10 test computer (I fell certain that WILL work on my Win7 systyems, but most of my client computers are Win10).

Ultimately the goal is to

  1. import a reg file to HKLM to elevate PowerShell executionPolicy to unrestricted,
  2. use Powershell to enable system protection/restore,
  3. use PowerShell create a restore point and finally
  4. import a reg file to set executionPolicy back to Restricted or RemoteSigned. (this is all being done as a pre-patching task, btw).

On my test computer, all this works well with the exception that regedit...even with the /s parameter...will not run without a UAC pop-up on Windows 10. I've seen this on my Win10 test computer.

I have tried running PowerShell elevated via bat file:

powershell.exe -ExecutionPolicy Bypass -File .\MyScript.ps1


PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList 'Set-ExecutionPolicy unrestricted -Force' -Verb RunAs}"

but these both fail (i.e. Access is denied, powershell executionpolicy is not elevated).

Importing the reg file and then running my Powershell script is the closest to success that I have achieved.

I have also tried this via Sysinternals psexec, based on other solutions searched for [i.e. psexec call to reg.exe to import] but that has its own set of problems (psexec needs a reg imported for the EULA, so same issue, not a solution).

Borrowing from that, I also tried running the following command:

C:\Windows\System32\REG.exe ADD HKLM\\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell /v ExecutionPolicy /t REG_SZ /d Unrestricted /f

...But that keeps coming back with "ERROR: Invalid key name." I've probably been working on this too long (3 days now) and just need another set of eyes. Can anyone assist?

  • In order to write to HKLM, you will NEED administrative privileges. Otherwise you would just get an Access Denied error. – LPChip Apr 6 '18 at 16:11
  • "import a reg file to HKLM to elevate PowerShell execution policy to unrestricted," - This requires elevated permission. You will be unable to modify this key without elevated permissions. You can change the policy within the script, provided the script, is elevated and/or ran as an elevated user. Have your system administrator make these changes for you. – Ramhound Apr 6 '18 at 23:03

Because you tried several different attempts, there are actually several problems you have pointed out within your post that could require an answer. You haven't made it clear how you are running any of these commands remotely. None of the commands you showed actually do anything on a remote computer. They all execute on the local computer. However, you did make mention of trying PSExec.

I am also unaware of any situation where UAC interferes with remote command execution. So, I can only assume you are running the commands on your local computer and experiencing UAC prompts. But, you are doing so in preparation to actually run the commands remotely.

So, I will try to give you some basic remote execution support that will get you on the right track. All remote execution of commands requires opening of certain firewall ports. So, keep that in mind as you move forward.

Powershell already has a remote command / script execution mechanism.

  • You can use the -ComputerName switch for certain commands to execute them on a remote system.
  • You can start an interactive remote session with, Enter-PSSession <ComputerName> and Exit-PSSession.
  • You can use the Invoke-Command -ComputerName <ComputerName> command to run any script or command remotely.

None of these methods are subject to the Execution Policy restriction, unless you start an interactive Powershell session and then proceed to try to execute a script.

These commands will run on the remote computer using your current logged in user account. If you are not an administrator on the remote machine, you will need to additionally provide a PSCredential object that is an administrator using the -Credential switch.


Alternatively, you can also use PSExec to run remote commands or executables. It is preferable to run these in the SYSTEM context to avoid ANY permission issues, but they are usually successful if you simply run them in the context of an administrator on the remote machine.

  • Bypass the EULA prompt with the -accepteula switch
  • Run in the SYSTEM context with the -s switch
  • Sometimes, utilizing the -i (interactive) switch is necessary to run certain 3rd party EXEcutables properly.

Commands executed via PSExec are not subject to UAC restrictions. However, if you try to run Powershell remotely via PSExec, which in turn tries to run a script, then the execution policy will get in the way unless you also utilize the -ExecutionPolicy Bypass switch. However, using PSExec to run Powershell remotely which in turn runs a script is a really long way to accomplish what you need to do.

Again, PSExec will establish a connection to the remote computer using your currently logged on user context. If you are not an administrator on the remote computer then you will need to specify a username / password that is using the -u and -p switches.


One last thing, you must always remember where the command is executing (locally or remotely) and realize that any resource you try to access is being done so from the perspective of where the command is being executed. For instance, if I run the command C:\MyBatch.bat on a remote computer, then C:\MyBatch.bat has to exist on the remote computer.

  • excellent answer...VERY illuminating. Thank you Appleoddity – Michael Boyd Apr 10 '18 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.