Skip to content

Commit

Permalink
fix(RunAsTI): quotes support
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Aug 4, 2023
1 parent 51afbf6 commit 6df1087
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/playbook/Executables/AtlasModules/Scripts/RunAsTI.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,23 @@ if not defined run_by (
goto RunAsTI-Elevate

----------------------------------------

[CREDITS]
- Adapted from https://github.com/AveYo/LeanAndMean
- Revised and customized for Atlas by he3als & Xyueta
- Added error checking and integration with script
- Added error checking, an interface and quotes support

[FEATURES]
- Innovative HKCU load, no need for 'reg load' or unload ping-pong; programs get the user profile
- Sets ownership privileges, high priority, and Explorer support; get System if TrustedInstaller is unavailable
- Accepts special characters in paths for which default 'Run as Administrator' fails

[LIMITATIONS]
- Quoatation marks ("") in arguments will not work correctly

[USAGE]
- Put this at the top of your script:

:: ------ Elevation ------ ::

whoami /user | find /i "S-1-5-18" > nul 2>&1 || (
call RunAsTI.cmd "%~f0" "%*"
exit /b
)

:: ----------------------- ::

----------------------------------------

:RunAsTI-Elevate
Expand Down Expand Up @@ -86,10 +77,10 @@ pause > nul
goto RunAsTI-Elevate

:RunAsTI
set ^ #=& set "0=%~f0"& set 1=%*
(for %%I in ("%~f0";%*) do @echo(%%~I) | PowerShell -NoProfile -Command "$argv = $input | ?{$_}; iex (${%~f0} | out-string)"
set "0=%~f0" & set "1=%*"
powershell -nop -c iex(gc """$env:0""" -Raw)
set RunAsTI_Errorlevel=%errorlevel%
if %RunAsTI_Errorlevel% == 1 (
if %RunAsTI_Errorlevel%==1 (
goto RunAsTI-Fail
) else (
if %RunAsTI_Errorlevel%==2 (
Expand Down

0 comments on commit 6df1087

Please sign in to comment.