Advertisement
sofaygo

Run Batch Script As Admin [VBS]

Apr 13th, 2024 (edited)
1,665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [[-]] VBS/Batch - Run Script As Admin [[-]]
  2.  
  3. VBS File:
  4. Set objShell = CreateObject("Shell.Application")
  5. Set objShellShell = CreateObject("WScript.Shell")
  6. strScriptPath = objShellShell.CurrentDirectory & "\replace with your file name.bat"
  7.  
  8. objShell.ShellExecute "cmd.exe", "/c """ & strScriptPath & """", "", "runas", 1
  9.  
  10. Save this as RunAsAdmin.vbs. Then, create a batch script to run this.
  11.  
  12. For example:
  13. @echo off
  14. RunAsAdmin.vbs >nul
  15. exit
Tags: vbs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement