Jump to content

Recommended Posts

Posted

Hi,

Wondering if anyone can help me with where im going wrong,

What id like to do is run a batch file as a domain user

all the files are located in the same folder 

 

i have the following.

 

$strDomain = "Domain"

$strUser = "user"

$strPass = "Password"

RunAsWait($strUser, $strDomain, $strPass, 0, 'CMD.exe' /c 'install.bat')

 

All is happening is it launching the CMD.exe as the above user.

 

Posted

i can run the install using the below command but i need run as a domain user.

RunWait(@ComSpec & " /C " & "name.bat", "", @SW_SHOW)

Im not sure what the syntax is ive tried the below.

RunWait(@ComSpec & " /C " & $strUser, $strDomain, $strPass,  "install.bat", "", @SW_SHOW)

Posted

You need to add #RequireAdmin, to run elevated, RunAs won't elevate a script even if that user is an administrator on the machine, unfortunately the script will prompt for credentials at that point.  You could use something like PSExec with -s to run as system account or you could use Task Scheduler.  You can also use Registry/Group Policy to allow all administrators to skip UAC prompting which should allow you to use RunAs without #RequireAdmin.

https://docs.microsoft.com/en-us/windows/security/identity-protection/user-account-control/user-account-control-group-policy-and-registry-key-settings#user-account-control-admin-approval-mode-for-the-built-in-administrator-account

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...