forked from nmap/npcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiagReport.bat
31 lines (25 loc) · 1.02 KB
/
DiagReport.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@echo off
whoami /Groups | find "S-1-16-12288" >NUL
if ERRORLEVEL 1 (
rem This tools must run with administrator permissions
rem It will popup the UAC dialog, please click [Yes] to continue.
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /b 2
)
set dir=%~dp0
set scriptPath=%dir%DiagReport.ps1
for /f "tokens=*" %%a in ('powershell Get-ExecutionPolicy') do (
set originPolicy=%%a
)
powershell Set-ExecutionPolicy 0
rem this call only works for Administrator
rem powershell %scriptPath%
rem This call works also for normal users
rem "No Exit" version:
rem powershell -NoExit -noprofile -command "&{start-process powershell -ArgumentList '-NoExit -noprofile -file \"%scriptPath%\"' -verb RunAs}"
rem "Exit" version:
powershell -noprofile -command "&{start-process powershell -ArgumentList '-noprofile -file \"%scriptPath%\"' -verb RunAs}"
powershell Set-ExecutionPolicy %originPolicy%
rem pause