Split PyScript and some cleanup

This commit is contained in:
Alan Mason 2017-11-22 14:50:55 -08:00
parent 00e0ff5e2d
commit 88bb009cf2

View file

@ -225,12 +225,12 @@ rem Prep
call :DeQuote prog call :DeQuote prog
call :DeQuote L_ARGS call :DeQuote L_ARGS
rem Create a temporary VB script to elevate the specified program rem Create VB script
mkdir "%bin%\tmp" 2>nul mkdir "%bin%\tmp" 2>nul
echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs" echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
echo UAC.ShellExecute "%prog%", "%L_ARGS%", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs" echo UAC.ShellExecute "%prog%", "%L_ARGS%", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
rem Run (via VB script) rem Run
"%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown "%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown
goto Exit goto Exit
@ -246,6 +246,7 @@ 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 rem Verify
if not exist "%script%" goto ErrorScriptNotFound if not exist "%script%" goto ErrorScriptNotFound
@ -261,9 +262,8 @@ if defined L_ELEV (
:LaunchPSScriptElev :LaunchPSScriptElev
rem Prep rem Prep
call :DeQuote script call :DeQuote script
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
rem Create a temporary VB script to elevate the specified program rem Create VB script
mkdir "%bin%\tmp" 2>nul mkdir "%bin%\tmp" 2>nul
echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs" echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
if defined L_NCMD ( if defined L_NCMD (
@ -278,9 +278,6 @@ rem Run
goto Exit goto Exit
:LaunchPSScriptUser :LaunchPSScriptUser
rem Prep
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
rem Run rem Run
if defined L_NCMD ( if defined L_NCMD (
start "" "%POWERSHELL%" %ps_args% -File "%script%" || goto ErrorUnknown start "" "%POWERSHELL%" %ps_args% -File "%script%" || goto ErrorUnknown
@ -292,28 +289,41 @@ goto Exit
:LaunchPyScript :LaunchPyScript
rem Prep rem Prep
call :ExtractOrFindPath || goto ErrorProgramNotFound call :ExtractOrFindPath || goto ErrorProgramNotFound
rem Set args
set "script=%_path%\%L_ITEM%" set "script=%_path%\%L_ITEM%"
rem Verify
if not exist "%script%" goto ErrorScriptNotFound if not exist "%script%" goto ErrorScriptNotFound
rem Run
if defined L_ELEV ( if defined L_ELEV (
goto LaunchPyScriptElev
) else (
goto LaunchPyScriptUser
)
:LaunchPyScriptElev
rem Prep
call :DeQuote script call :DeQuote script
rem Create VB script
mkdir "%bin%\tmp" 2>nul 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" echo Set UAC = CreateObject^("Shell.Application"^) > "%bin%\tmp\Elevate.vbs"
if defined L_NCMD ( if defined L_NCMD (
rem use Python's window instead of %CON% echo UAC.ShellExecute "%PYTHON%", "%script%", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
echo UAC.ShellExecute "%PYTHON%", "!script!", "", "runas", 3 >> "%bin%\tmp\Elevate.vbs"
) else ( ) else (
echo UAC.ShellExecute "%CON%", "-run %PYTHON% !script! -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs" echo UAC.ShellExecute "%CON%", "-run %PYTHON% %script% -new_console:n", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
) )
rem Run
"%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown "%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown
) else ( goto Exit
:LaunchPyScriptUser
if defined L_NCMD ( if defined L_NCMD (
start "" "%PYTHON%" "%script%" || goto ErrorUnknown start "" "%PYTHON%" "%script%" || goto ErrorUnknown
) else ( ) else (
start "" "%CON%" -run "%PYTHON%" "%script%" -new_console:n || goto ErrorUnknown start "" "%CON%" -run "%PYTHON%" "%script%" -new_console:n || goto ErrorUnknown
) )
)
goto Exit goto Exit
:LaunchQuickBooksSetup :LaunchQuickBooksSetup