Advertisement
FreeBooter

Add_Open_command_window_here_as_administrator

Aug 21st, 2022
1,909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.00 KB | Fixit | 0 0
  1. ::  Add "Open command window here as administrator" context menu in Windows 10 and Windows 11
  2.  
  3. @Echo Off & Cls
  4.  
  5.  
  6. (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
  7.  
  8. :choice
  9.  
  10. Cls & Mode CON  LINES=11 COLS=95 & Color 0E & Title Created By FreeBooter
  11. Echo.
  12. Echo.
  13. Echo.
  14. Echo        Add "Open command window here as administrator" to Context Menu       (A)  
  15. Echo.      
  16. Echo        Remove "Open command window here as administrator" from Context Menu  (R)
  17. Echo.
  18.  
  19.  
  20. Set /p input=^>
  21.  
  22. If /i  Not %input%==A (Goto :_Ex) Else (Goto :_Add)
  23.  
  24. :_Ex
  25. If /i Not %input%==R  (Goto :choice) Else (Goto :_Remove)
  26.  
  27.  
  28.  
  29. :_Add
  30.  
  31. Reg.exe add "HKCR\Directory\shell\OpenCmdHereAsAdmin" /ve /t REG_SZ /d "Open command window here as administrator" /f
  32. Reg.exe delete "HKCR\Directory\shell\OpenCmdHereAsAdmin" /v "Extended" /f
  33. Reg.exe add "HKCR\Directory\shell\OpenCmdHereAsAdmin" /v "Icon" /t REG_SZ /d "imageres.dll,-5324" /f
  34. Reg.exe add "HKCR\Directory\shell\OpenCmdHereAsAdmin\command" /ve /t REG_SZ /d "cmd /c echo|set/p=\"%%L\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\"" /f
  35. Reg.exe add "HKCR\Directory\Background\shell\OpenCmdHereAsAdmin" /ve /t REG_SZ /d "Open command window here as administrator" /f
  36. Reg.exe delete "HKCR\Directory\Background\shell\OpenCmdHereAsAdmin" /v "Extended" /f
  37. Reg.exe add "HKCR\Directory\Background\shell\OpenCmdHereAsAdmin" /v "Icon" /t REG_SZ /d "imageres.dll,-5324" /f
  38. Reg.exe add "HKCR\Directory\Background\shell\OpenCmdHereAsAdmin\command" /ve /t REG_SZ /d "cmd /c echo|set/p=\"%%V\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\"" /f
  39. Reg.exe add "HKCR\Drive\shell\OpenCmdHereAsAdmin" /ve /t REG_SZ /d "Open command window here as administrator" /f
  40. Reg.exe delete "HKCR\Drive\shell\OpenCmdHereAsAdmin" /v "Extended" /f
  41. Reg.exe add "HKCR\Drive\shell\OpenCmdHereAsAdmin" /v "Icon" /t REG_SZ /d "imageres.dll,-5324" /f
  42. Reg.exe add "HKCR\Drive\shell\OpenCmdHereAsAdmin\command" /ve /t REG_SZ /d "cmd /c echo|set/p=\"%%L\"|powershell -NoP -W 1 -NonI -NoL \"SaPs 'cmd' -Args '/c \"\"\"cd /d',$([char]34+$Input+[char]34),'^&^& start /b cmd.exe\"\"\"' -Verb RunAs\"" /f
  43. Reg.exe delete "HKCR\LibraryFolder\background\shell\OpenCmdHereAsAdmin" /f
  44. REM ; To allow mapped drives to be available in command prompt
  45. Reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLinkedConnections" /t REG_DWORD /d "1" /f
  46.  
  47. Goto :RestartEx
  48.  
  49.  
  50.  
  51. :_Remove
  52.  
  53. Reg.exe delete "HKCR\Directory\shell\OpenCmdHereAsAdmin" /f
  54. Reg.exe delete "HKCR\Directory\Background\shell\OpenCmdHereAsAdmin" /f
  55. Reg.exe delete "HKCR\Drive\shell\OpenCmdHereAsAdmin" /f
  56. Reg.exe delete "HKCR\LibraryFolder\background\shell\OpenCmdHereAsAdmin" /f
  57. Reg.exe delete "HKCR\LibraryFolder\background\shell\OpenCmdHereAsAdmin\command" /f
  58.  
  59.  
  60.  
  61. :RestartEx
  62.  
  63. Taskkill /im Explorer.exe /f >Nul
  64.  
  65. Start Explorer.exe
  66.  
  67. Exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement