Skip to content

Instantly share code, notes, and snippets.

@heiwa4126
Created March 31, 2021 06:42
Show Gist options
  • Save heiwa4126/49e60ebee90cb2f32850bd71f915c971 to your computer and use it in GitHub Desktop.
Save heiwa4126/49e60ebee90cb2f32850bd71f915c971 to your computer and use it in GitHub Desktop.
.batをダブルクリックで管理者権限で実行する。ダイアログはでるけど「右クリックで管理者権限で実行」よりは全然楽。もとは https://4thsight.xyz/13971 。空白を含むパスで実行すると死ぬバグを直した。
@echo off
cd /d "%~dp0"
for /f "tokens=3 delims=\ " %%i in ('whoami /groups^|find "Mandatory"') do set LEVEL=%%i
if NOT "%LEVEL%"=="High" (
powershell.exe -NoProfile -ExecutionPolicy RemoteSigned -Command "Start-Process \"%~f0\" -Verb runas"
exit
)
rem これ以降に、実行したい処理を記述します
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment