flash17 Posted April 12, 2017 Posted April 12, 2017 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
jguinch Posted April 12, 2017 Posted April 12, 2017 The user "Testing" has admin rights ? (member of the administrators group ?) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
flash17 Posted April 12, 2017 Author Posted April 12, 2017 Hey, Testing is a member of the administrators group.
jguinch Posted April 12, 2017 Posted April 12, 2017 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) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
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