Advertisement
_LINKI

Easy sudo in Windows CMD/PowerShell -> with multiple commands support through sudo args

Sep 23rd, 2023
1,505
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Winbatch 0.47 KB | Source Code | 0 0
  1. @echo off
  2.  
  3. rem Original github gist - https://gist.github.com/TheJustLink/1f1707f971c81273339525558537c1e0
  4.  
  5. SetLocal EnableDelayedExpansion
  6.  
  7. set argument=%*
  8.  
  9. set argument=!argument:"="!
  10. set argument=!argument:'=''!
  11.  
  12. set firstSymbol=%argument:~0,1%
  13. set checkSymbol="
  14.  
  15. if !firstSymbol! == !checkSymbol! (
  16.   set argument=!argument:~1,-1!
  17. )
  18.  
  19. powershell -Command "Start-Process cmd -ArgumentList(('/k cd {0}' -f (Get-Location).path), '& !argument!') -Verb RunAs"
  20. exit
Advertisement
Comments
  • _LINKI
    234 days
    # text 0.21 KB | 0 0
    1. Original github gist - https://gist.github.com/TheJustLink/1f1707f971c81273339525558537c1e0
    2.  
    3. Add sudo.cmd to PATH and use anywhere you want
    4.  
    5. Examples:
    6.  
    7. sudo
    8. sudo echo Hello World!
    9. sudo "echo 1 & echo 2"
Add Comment
Please, Sign In to add comment
Advertisement