Jump to content

call a spowershell script to run elevated


Go to solution Solved by goodmanjl531,

Recommended Posts

I am trying to run a powershell script elevated that will add a new printer port.  the powershell script works fine when call from an elevated command prompt but I can't seem to call this via auto it.

 

 

Local $sUserName = ""      ; Place Admin User ID here.
Local $sPassword = ""   ; Place Admin Password here.

#include <Date.au3>




SplashTextOn(" Inc.","Running Printer IP update Please Wait.....","-1","-1","-1","-1",0,"","","")


_WriteLog("Installation Started : ")
FileInstall("C:\TS\CloudScripts\Reconfigure-Printer-V0.5.ps1","C:\ts\Reconfigure-Printer-V0.5.ps1",1)



$Result = RunAsWait($sUserName, @ComputerName, $sPassword, 0,@ComSpec & " /c " & 'powershell.exe -file Reconfigure-Printer-V0.5.ps1', "", @SW_HIDE)
_WriteLog("POWERSHELL SCRIPT RAN : " & $Result)


;$Result=RunAsWait($sUserName, @ComputerName, $sPassword, 0, "powershell.exe -file Reconfigure-Printer-V0.5.ps1"); Run Powershell script to rest printer
;_WriteLog("CBTS Powersehll script executed :"& $Result)
Sleep(5000)


_WriteLog("Installation Completed: ")
SplashOff()
SplashTextOn(" Inc.","Printer RE-IP Complete","-1","-1","-1","-1",0,"","","")
Sleep(5000)
SplashOff()
Func _WriteLog($Message)
    FileWriteLine(@ScriptDir & "\" & @ScriptName & ".log", @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & ": " & $Message)
EndFunc   ;==>_WriteLog

 

Edited by goodmanjl531
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...