Advertisement
Guest User

Save cmd?

a guest
Mar 14th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. @echo off
  2. CLS
  3. ECHO.
  4. ECHO =============================
  5. ECHO Running Admin shell
  6. ECHO =============================
  7.  
  8. :init
  9. setlocal DisableDelayedExpansion
  10. set cmdInvoke=1
  11. set winSysFolder=System32
  12. set "batchPath=%~0"
  13. for %%k in (%0) do set batchName=%%~nk
  14. set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
  15. setlocal EnableDelayedExpansion
  16.  
  17. :checkPrivileges
  18. NET FILE 1>NUL 2>NUL
  19. if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
  20.  
  21. :getPrivileges
  22. if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
  23. ECHO.
  24. ECHO **************************************
  25. ECHO Invoking UAC for Privilege Escalation
  26. ECHO **************************************
  27.  
  28. ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
  29. ECHO args = "ELEV " >> "%vbsGetPrivileges%"
  30. ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
  31. ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
  32. ECHO Next >> "%vbsGetPrivileges%"
  33.  
  34. if '%cmdInvoke%'=='1' goto InvokeCmd
  35.  
  36. ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  37. goto ExecElevation
  38.  
  39. :InvokeCmd
  40. ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
  41. ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"
  42.  
  43. :ExecElevation
  44. "%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
  45. exit /B
  46.  
  47. :gotPrivileges
  48. setlocal & cd /d %~dp0
  49. if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
  50.  
  51. ::::::::::::::::::::::::::::
  52. ::START
  53. ::::::::::::::::::::::::::::
  54. echo Stopping Sandboxie services/tasks ...
  55. echo.
  56.  
  57. taskkill /F /T /IM SbieSvc.exe
  58. taskkill /F /T /IM SbieCtrl.exe
  59.  
  60. echo.
  61. pause
  62.  
  63. @exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement