Jump to content
Darien

Access denied when running command "runas" after updating Windows 10

Recommended Posts

Darien

Hello,

 

I have a program that performs the command below:

 

$pid = RunAs ( "administrator" , @ComputerName , "<administrator password>" , 0 , @ComSpec & " /c reg add ""HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run"" /t REG_SZ /v ""example"" /d ""C:\example.exe"" /f" , "" , @SW_HIDE , $STDERR_CHILD + $STDOUT_CHILD )

$resultado = ""
$erro           = ""

    While 1

        $resultado = $resultado & StdoutRead ( $pid )
        $erro          = $erro             & StderrRead ( $pid )

        If @error Then ExitLoop

    WEnd

MsgBox ( 0 , $resultado & "|" & $erro )

 

After a Windows upgrade (probably the 1709), the "reg add" command has resulted in the "Access denied" message.

What could correct this?

 

Share this post


Link to post
Share on other sites
benched42

Not sure your syntax for the "reg" command is correct. From the help file for "reg add" found by typing "reg add /?" into a command prompt window, the REG command is lookinf for HKLM, HKCU, HKCR, HKU or HKCC. The full name of the root key is not acceptable.

REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]
        [/reg:32 | /reg:64]

  KeyName  [\\Machine\]FullKey
           Machine  Name of remote machine - omitting defaults to the
                    current machine. Only HKLM and HKU are available on remote
                    machines.
           FullKey  ROOTKEY\SubKey
           ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
           SubKey   The full name of a registry key under the selected ROOTKEY.


Who lied and told you life would EVER be fair?

Share this post


Link to post
Share on other sites
Darien

I discovered: you need to disable security policy "User Account Control: Admin Approval Mode for the Built-in Administrator account", which is enabled by the update.

Share this post


Link to post
Share on other sites
AdamUL

Just an FYI.  You can set this setting with AutoIt by using the UAC UDF.  

#RequireAdmin
#include <UAC.au3>
If _UAC_GetFilterAdministratorToken() = $UAC_ENABLED Then _UAC_SetFilterAdministratorToken($UAC_DISABLED)

 

Adam

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×