jeffhoward001 Posted January 24, 2012 Share Posted January 24, 2012 Hello - I've spent considerable time searching the forums and trying different calls to RunAs and RunAsWait to accomplish what I'm looking for, but I feel like I'm missing a crucial step. My end-goal is simply this: Run a program in a console window with an account with higher-level priviledges, and have the user be able to interact with the called process as if they launched it from the console window. Why do I want to do this? Basically because we lock down our Dev/Test environments such that developers don't do silly things like install odd binaries or make compromising configurations to Windows. The only downside is, there are some processes that require admin perms that we'd like the developers to be able to change in a controlled fashion. Which is exactly where AutoIT makes sense - I can write scripts that control exactly how the user changes system level parameters. So my realistic example is, I want to be able to run the Deploy.cmd command with an elevated account such that it can interact with system level components like IIS, and have all the stderr & stdout displayed in the same window that the user lauched the compiled .exe generated with AutoIT. Is this possible? ; Fill in the username and password appropriate for your system. #include "Constants.au3" Local $sUserName = "" Local $sPassword = "" ; Local $sProgram = "C:\Windows\System32\cmd.exe /C C:\IT\Deploy.cmd" Local $sProgram = "C:\Windows\System32\whoami.exe" Local $sWorkingDir = "C:\IT\workingfiles" If @ComputerName = "TESTWEB" Then $sUserName = "TestAccount" $sPassword = "XXXXXXXXXXXXXX" EndIf If @ComputerName = "DEVWEB" Then $sUserName = "DevAccount" $sPassword = "XXXXXXXXXXXXXX" EndIf If $sUserName = "" Then ConsoleWrite("Error!") Exit EndIf ConsoleWrite("Starting " & $sProgram & " with the following parameters: Username: " & $sUsername & " Password: " & $sPassword) ; Run a command prompt as the other user. RunAsWait($sUserName, @ComputerName, $sPassword, 4, $sProgram, $sWorkingDir,@SW_MAXIMIZE ,$STDERR_MERGED) ConsoleWrite(@CRLF & "Done...") Link to comment Share on other sites More sharing options...
SCarter Posted October 29, 2013 Share Posted October 29, 2013 Did anyone else run into this problem? I am getting error 1326 when I use logon flag = 0 or 1, error 267 when I use logon flag 2, and error 1783 when I use logon flag 4 Link to comment Share on other sites More sharing options...
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