Skip to content

Instantly share code, notes, and snippets.

@mistificator
Last active September 22, 2018 20:42
Show Gist options
  • Save mistificator/332c893acaf66186af25957ed471e2ed to your computer and use it in GitHub Desktop.
Save mistificator/332c893acaf66186af25957ed471e2ed to your computer and use it in GitHub Desktop.
@echo off
:-------------------------------------
REM --> Check for permissions
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
powershell.exe Start-Process -Wait -Verb runAs -FilePath "cmd.exe" -ArgumentList "/s","/c","%~f0"
exit /b
)
set current_dir=%~dp0
cd %current_dir%
%current_dir:~0,2%
REM --> Exec batch
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment