a4r0 Posted April 3, 2020 Posted April 3, 2020 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.
a4r0 Posted April 3, 2020 Author Posted April 3, 2020 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)
Nine Posted April 3, 2020 Posted April 3, 2020 This should be working : Local $iRet = RunAsWait($strUser, $strDomain, $strPass, 0, @comspec & " /c install.bat", "", @SW_SHOW) ConsoleWrite ($iRet & "/" & @error & @CRLF) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Subz Posted April 3, 2020 Posted April 3, 2020 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now