Jump to content

RunAs Windows 10 Not Working


Recommended Posts

Hey,

 

I am new to scripting and AutoIt and have done extensive reserach on the forums, to try and resolve my issue. So I apologize if this is a repost.

I am trying to create a .au3 compiled .exe that will allow our end users restart a specifice service, net stop spooler. I have successfully gotten it to work with #RequireAdmin, as it will then prompt for admin credentials. However, when I use the below script, it does nothing and I am stumped.

 

Local $strUusername = "Testing"
Local $strPassword = "Password1"
Local $strDomain = @ComputerName

Runas($strUusername, $strDomain, $strPassword, 0, "Net Start Spooler", "", @SW_HIDE)

 

I have confirmed that the spooler is not actually stopped after running this. Does anyone have any suggestions or thoughts as to what I am doing wrong? I am currently testing with a local test admin account, but will ultimately want to use a domain account.

 

Please let me know if I need to add anything else. I look forward to any assistance that can be offered.

 

Thanks

Link to comment
Share on other sites

You can try something like this :

#pragma compile(AutoItExecuteAllowed, True)

Local $strUusername = "Testing"
Local $strPassword = "Password1"
Local $strDomain = @ComputerName

Local $sTempAu3 = @WindowsDir & "\temp\stopSpooler.au3"

Local $sScript = '#RequireAdmin' & @CRLF & _
                 'Local $oShell = ObjCreate("shell.application")' & @CRLF & _
                 '$oShell.ServiceStop("spooler",false)'

Local $hScript = FileOpen($sTempAu3, 2)
FileWrite($hScript, $sScript)
FileClose($hScript)

Runas($strUusername, $strDomain, $strPassword, 0, @ScriptFullPath & ' /AutoIt3ExecuteScript "' & $sTempAu3 & '"' , '', @SW_HIDE)

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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