Batch Script to Run as Administrator

后端 未结 12 2083
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 11:18

I\'m writing a client/server checking program but it needs to run as Administrator.

I want this to run silently on my network and users, and I don\'t want the \"Run

12条回答
  •  春和景丽
    2020-12-13 11:40

    If all above answers is not to your liking you can use autoIT to run your file (or what ever file) as a specific user with their credentials.

    Sample of a script that will run a program using that users privelages.

    installAdmin()
    
    Func installAdmin()
        ; Change the username and password to the appropriate values for your system.
        Local $sUserName = "xxxxx"
        Local $sPassword = "xxx"
        Local $sDirectory = "C:\ASD4VM\Download\"
        Local $sFiletoRun = "Inst_with_Privileges.bat"
    
        RunAsWait($sUserName, @ComputerName, $sPassword, 0, $sDirectory & $sFiletoRun)
    EndFunc   ;==>Example
    

    AutoIT can be found here. -> It uses a .ua3 format that is compiled to a .exe file that can be run.

提交回复
热议问题