-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.cmd
21 lines (19 loc) · 956 Bytes
/
admin.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@setlocal & echo off
@REM // ============================================================================================
@REM // admin.cmd -- Administrator launch script
@REM //
@REM // This script checks the current permission level of the invoking shell. If it currently
@REM // has administrator privilege, it executes the command given on the remainder of the
@REM // command line. If the current shell does not have administrator privilege, it launches
@REM // a new administrator shell, and then executes the command.
@REM //
@REM // ============================================================================================
REM // Check for admin rights
net file 1>nul 2>&1
if %errorlevel% equ 0 (
call %*
) else (
echo Launching Administrator shell.
powershell -ex unrestricted ^
-Command "Start-Process -Verb RunAs -FilePath '%comspec%' -ArgumentList '/k cd /d \"%cd:\=/%\" & %*'"
)