นี่คือสคริปต์แบทช์บรรทัดคำสั่งหากมีคนต้องการโซลูชันคลิกเดียว คุณจะต้องวาง SubInACL.exe ในโฟลเดอร์ที่มีสคริปต์ (รับที่นี่จาก Microsoft)
@echo off
Setlocal EnableDelayedExpansion
:check_admin
NET FILE 1>NUL 2>NUL
IF ERRORLEVEL 1 (
cls
echo Starting as admin ...
powershell "saps -filepath %0 -verb runas" >nul 2>&1
exit
)
cls
:set_privileges
rem Enable explorer to run privileged, src: https://superuser.com/a/591082/145585
echo Setting permissions ...
rem change owner to Administrators
rem should report: Done: 1, Modified 1, Failed 0, Syntax errors 0
%~dp0subinacl.exe /noverbose /statistic /subkeyreg "HKEY_CLASSES_ROOT\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}" /setowner=administrators >nul 2>nul
rem give Administrators full permission
rem should report: Done: 1, Modified 1, Failed 0, Syntax errors 0
%~dp0subinacl.exe /noverbose /statistic /subkeyreg "HKEY_CLASSES_ROOT\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}" /grant=administrators=f >nul 2>nul
echo Rename registry entry ...
powershell -ExecutionPolicy Bypass -Command "Rename-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\AppID\{CDCBCFCA-3CDC-436f-A4E2-0E02075250C2}' -Name 'RunAs' -NewName '_Runas' -ErrorAction SilentlyContinue"
:run_explorer
echo Starting explorer ...
start "" /MAX "c:\windows\explorer.exe" "%~dp0"