Split PSScript section
This commit is contained in:
parent
c526c3d1b9
commit
00e0ff5e2d
1 changed files with 37 additions and 17 deletions
|
|
@ -246,26 +246,46 @@ goto Exit
|
||||||
rem Prep
|
rem Prep
|
||||||
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
||||||
set "script=%_path%\%L_ITEM%"
|
set "script=%_path%\%L_ITEM%"
|
||||||
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
|
|
||||||
|
rem Verify
|
||||||
if not exist "%script%" goto ErrorScriptNotFound
|
if not exist "%script%" goto ErrorScriptNotFound
|
||||||
|
|
||||||
|
rem Run
|
||||||
|
popd && pushd "%_path%"
|
||||||
if defined L_ELEV (
|
if defined L_ELEV (
|
||||||
call :DeQuote script
|
goto LaunchPSScriptElev
|
||||||
mkdir "%bin%\tmp" 2>nul
|
|
||||||
rem Create a temporary VB script to elevate the specified program
|
|
||||||
echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
|
|
||||||
if defined L_NCMD (
|
|
||||||
rem use Powershell's window instead of %CON%
|
|
||||||
echo UAC.ShellExecute "%POWERSHELL%", "%ps_args% -File "!script!"", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
|
|
||||||
) else (
|
|
||||||
echo UAC.ShellExecute "%CON%", "-run %POWERSHELL% %ps_args% -File "!script!" -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
|
|
||||||
)
|
|
||||||
"%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown
|
|
||||||
) else (
|
) else (
|
||||||
if defined L_NCMD (
|
goto LaunchPSScriptUser
|
||||||
start "" "%POWERSHELL%" %ps_args% -File "%script%" || goto ErrorUnknown
|
)
|
||||||
) else (
|
|
||||||
start "" "%CON%" -run "%POWERSHELL%" %ps_args% -File "%script%" -new_console:n || goto ErrorUnknown
|
:LaunchPSScriptElev
|
||||||
)
|
rem Prep
|
||||||
|
call :DeQuote script
|
||||||
|
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
|
||||||
|
|
||||||
|
rem Create a temporary VB script to elevate the specified program
|
||||||
|
mkdir "%bin%\tmp" 2>nul
|
||||||
|
echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
|
||||||
|
if defined L_NCMD (
|
||||||
|
rem use Powershell's window instead of %CON%
|
||||||
|
echo UAC.ShellExecute "%POWERSHELL%", "%ps_args% -File "%script%"", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
|
||||||
|
) else (
|
||||||
|
echo UAC.ShellExecute "%CON%", "-run %POWERSHELL% %ps_args% -File "%script%" -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
|
||||||
|
)
|
||||||
|
|
||||||
|
rem Run
|
||||||
|
"%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown
|
||||||
|
goto Exit
|
||||||
|
|
||||||
|
:LaunchPSScriptUser
|
||||||
|
rem Prep
|
||||||
|
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
|
||||||
|
|
||||||
|
rem Run
|
||||||
|
if defined L_NCMD (
|
||||||
|
start "" "%POWERSHELL%" %ps_args% -File "%script%" || goto ErrorUnknown
|
||||||
|
) else (
|
||||||
|
start "" "%CON%" -run "%POWERSHELL%" %ps_args% -File "%script%" -new_console:n || goto ErrorUnknown
|
||||||
)
|
)
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue