Split Program and Office sections
* Also renamed TestPath for clarity
This commit is contained in:
parent
bd649f2189
commit
c526c3d1b9
1 changed files with 109 additions and 68 deletions
|
|
@ -84,7 +84,7 @@ if defined RELOAD_IN_CONEMU (
|
||||||
rem Jump to the selected launch type or show usage
|
rem Jump to the selected launch type or show usage
|
||||||
if /i "%L_TYPE%" == "Console" (goto LaunchConsole)
|
if /i "%L_TYPE%" == "Console" (goto LaunchConsole)
|
||||||
if /i "%L_TYPE%" == "Folder" (goto LaunchFolder)
|
if /i "%L_TYPE%" == "Folder" (goto LaunchFolder)
|
||||||
if /i "%L_TYPE%" == "Office" (goto LaunchOfficeSetup)
|
if /i "%L_TYPE%" == "Office" (goto LaunchOffice)
|
||||||
if /i "%L_TYPE%" == "QuickBooks" (goto LaunchQuickBooksSetup)
|
if /i "%L_TYPE%" == "QuickBooks" (goto LaunchQuickBooksSetup)
|
||||||
if /i "%L_TYPE%" == "Program" (goto LaunchProgram)
|
if /i "%L_TYPE%" == "Program" (goto LaunchProgram)
|
||||||
if /i "%L_TYPE%" == "PSScript" (goto LaunchPSScript)
|
if /i "%L_TYPE%" == "PSScript" (goto LaunchPSScript)
|
||||||
|
|
@ -92,8 +92,8 @@ if /i "%L_TYPE%" == "PyScript" (goto LaunchPyScript)
|
||||||
goto Usage
|
goto Usage
|
||||||
|
|
||||||
:LaunchConsole
|
:LaunchConsole
|
||||||
rem Test L_PATH and set %_path%
|
rem Prep
|
||||||
call :TestPath || goto ErrorProgramNotFound
|
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
||||||
|
|
||||||
rem Check for 64-bit prog (if running on 64-bit system)
|
rem Check for 64-bit prog (if running on 64-bit system)
|
||||||
set "prog=%_path%\%L_ITEM%"
|
set "prog=%_path%\%L_ITEM%"
|
||||||
|
|
@ -111,103 +111,140 @@ if defined L_NCMD (
|
||||||
)
|
)
|
||||||
|
|
||||||
:LaunchConsoleConEmu
|
:LaunchConsoleConEmu
|
||||||
rem Set args
|
rem Prep
|
||||||
set "con_args=-new_console:n"
|
set "con_args=-new_console:n"
|
||||||
if defined DEBUG (set "con_args=%con_args% -new_console:c")
|
if defined DEBUG (set "con_args=%con_args% -new_console:c")
|
||||||
if defined L_ELEV (set "con_args=%con_args% -new_console:a")
|
if defined L_ELEV (set "con_args=%con_args% -new_console:a")
|
||||||
|
|
||||||
|
rem Run
|
||||||
start "" "%CON%" -run "%prog%" %L_ARGS% %con_args% || goto ErrorUnknown
|
start "" "%CON%" -run "%prog%" %L_ARGS% %con_args% || goto ErrorUnknown
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
:LaunchConsoleNative
|
:LaunchConsoleNative
|
||||||
start "" /wait "%prog%" %L_ARGS% || goto ErrorUnknown
|
rem Prep
|
||||||
|
if defined L_WAIT (set "wait=/wait")
|
||||||
|
|
||||||
|
rem Run
|
||||||
|
start "" %wait% "%prog%" %L_ARGS% || goto ErrorUnknown
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
:LaunchFolder
|
:LaunchFolder
|
||||||
rem Test L_PATH and set %_path% (extracts archive in necessary)
|
rem Prep
|
||||||
call :TestPath || goto ErrorProgramNotFound
|
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
||||||
|
|
||||||
|
rem Run
|
||||||
start "" "explorer.exe" "%_path%" || goto ErrorUnknown
|
start "" "explorer.exe" "%_path%" || goto ErrorUnknown
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
:LaunchOfficeSetup
|
:LaunchOffice
|
||||||
rem set args and copy setup files to system
|
|
||||||
rem NOTE: init_client_dir.cmd sets %client_dir% and creates %client_dir%\Office folder
|
|
||||||
call "%bin%\Scripts\init_client_dir.cmd" /Office
|
call "%bin%\Scripts\init_client_dir.cmd" /Office
|
||||||
echo Copying setup file(s) for %L_ITEM%...
|
|
||||||
rem NOTE: If L_PATH == "2013" or "2016" extract the ODT setup/xml, otherwise copy from OFFICE_SERVER
|
|
||||||
set "_odt=False"
|
set "_odt=False"
|
||||||
if %L_PATH% equ 2013 (set "_odt=True")
|
if %L_PATH% equ 2013 (set "_odt=True")
|
||||||
if %L_PATH% equ 2016 (set "_odt=True")
|
if %L_PATH% equ 2016 (set "_odt=True")
|
||||||
if "%_odt%" == "True" (
|
if "%_odt%" == "True" (
|
||||||
rem extract setup/xml and start installation
|
goto LaunchOfficeODT
|
||||||
set "source=%L_PATH%\setup.exe"
|
|
||||||
set "dest=%client_dir%\Office\%L_PATH%"
|
|
||||||
"%SEVEN_ZIP%" e "%cbin%\_Office.7z" -aoa -bso0 -bse0 -p%ARCHIVE_PASSWORD% -o"!dest!" !source! !L_ITEM! || exit /b 1
|
|
||||||
"%systemroot%\System32\ping.exe" -n 2 127.0.0.1>nul
|
|
||||||
if not exist "!dest!\setup.exe" (goto ErrorOfficeSourceNotFound)
|
|
||||||
if not exist "!dest!\!L_ITEM!" (goto ErrorOfficeSourceNotFound)
|
|
||||||
pushd "!dest!"
|
|
||||||
rem # The line below jumps to ErrorUnknown even though setup.exe is run correctly??
|
|
||||||
rem start "" "setup.exe" /configure !L_ITEM! || popd & goto ErrorUnknown
|
|
||||||
rem # Going to assume it extracted correctly and blindly start setup.exe
|
|
||||||
start "" "setup.exe" /configure !L_ITEM!
|
|
||||||
popd
|
|
||||||
) else (
|
) else (
|
||||||
rem copy setup files from OFFICE_SERVER
|
goto LaunchOfficeSetup
|
||||||
set "fastcopy_args=/cmd=diff /no_ui /auto_close"
|
)
|
||||||
set "product=%L_PATH%\%L_ITEM%"
|
|
||||||
set "product_name=%L_ITEM%"
|
:LaunchOfficeODT
|
||||||
call :GetBasename product_name || goto ErrorBasename
|
rem Prep
|
||||||
set "source=\\%OFFICE_SERVER%\Office\!product!"
|
set "args=-aoa -bso0 -bse0 -bsp0 -p%ARCHIVE_PASSWORD%"
|
||||||
set "dest=%client_dir%\Office"
|
set "config=%L_ITEM%"
|
||||||
rem Verify source
|
set "dest=%client_dir%\Office\%L_PATH%"
|
||||||
if not exist "!source!" (goto ErrorOfficeSourceNotFound)
|
set "odt_exe=%L_PATH%\setup.exe"
|
||||||
rem Copy setup file(s) to system
|
set "source=%cbin%\_Office.7z"
|
||||||
start "" /wait "%FASTCOPY%" !fastcopy_args! "!source!" /to="!dest!\"
|
|
||||||
rem Run setup
|
rem Extract
|
||||||
if exist "!dest!\!product_name!\setup.exe" (
|
if not exist "%source%" (goto ErrorODTSourceNotFound)
|
||||||
start "" "!dest!\!product_name!\setup.exe" || goto ErrorUnknown
|
"%SEVEN_ZIP%" e "%source%" %args% -o"%dest%" %odt_exe% %config% || exit /b 1
|
||||||
) else if "!product_name:~-3,3!" == "exe" (
|
"%systemroot%\System32\ping.exe" -n 2 127.0.0.1>nul
|
||||||
start "" "!dest!\!product_name!" || goto ErrorUnknown
|
|
||||||
) else if "!product_name:~-3,3!" == "msi" (
|
rem Verify
|
||||||
start "" "!dest!\!product_name!" || goto ErrorUnknown
|
if not exist "%dest%\setup.exe" (goto ErrorODTSourceNotFound)
|
||||||
) else (
|
if not exist "%dest%\%config%" (goto ErrorODTSourceNotFound)
|
||||||
rem Office source not supported by this script
|
pushd "%dest%"
|
||||||
goto ErrorOfficeUnsupported
|
|
||||||
)
|
rem Run
|
||||||
|
rem # The line below jumps to ErrorUnknown even when it runs correctly??
|
||||||
|
rem start "" "setup.exe" /configure %L_ITEM% || popd & goto ErrorUnknown
|
||||||
|
rem # Going to assume it extracted correctly and blindly start setup.exe
|
||||||
|
start "" "setup.exe" /configure %config%
|
||||||
|
popd
|
||||||
|
goto Exit
|
||||||
|
|
||||||
|
:LaunchOfficeSetup
|
||||||
|
rem Prep
|
||||||
|
set "fastcopy_args=/cmd=diff /no_ui /auto_close"
|
||||||
|
set "product=%L_PATH%\%L_ITEM%"
|
||||||
|
set "product_name=%L_ITEM%"
|
||||||
|
call :GetBasename product_name || goto ErrorBasename
|
||||||
|
set "source=\\%OFFICE_SERVER%\Office\!product!"
|
||||||
|
set "dest=%client_dir%\Office"
|
||||||
|
|
||||||
|
rem Verify
|
||||||
|
if not exist "!source!" (goto ErrorOfficeSourceNotFound)
|
||||||
|
|
||||||
|
rem Copy
|
||||||
|
start "" /wait "%FASTCOPY%" !fastcopy_args! "!source!" /to="!dest!\"
|
||||||
|
|
||||||
|
rem Run
|
||||||
|
if exist "!dest!\!product_name!\setup.exe" (
|
||||||
|
start "" "!dest!\!product_name!\setup.exe" || goto ErrorUnknown
|
||||||
|
) else if "!product_name:~-3,3!" == "exe" (
|
||||||
|
start "" "!dest!\!product_name!" || goto ErrorUnknown
|
||||||
|
) else if "!product_name:~-3,3!" == "msi" (
|
||||||
|
start "" "!dest!\!product_name!" || goto ErrorUnknown
|
||||||
|
) else (
|
||||||
|
rem Office source not supported by this script
|
||||||
|
goto ErrorOfficeUnsupported
|
||||||
)
|
)
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
:LaunchProgram
|
:LaunchProgram
|
||||||
rem Test L_PATH and set %_path%
|
rem Prep
|
||||||
call :TestPath || goto ErrorProgramNotFound
|
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
||||||
|
|
||||||
rem Check for 64-bit prog (if running on 64-bit system)
|
rem Check for 64-bit prog (if running on 64-bit system)
|
||||||
set "prog=%_path%\%L_ITEM%"
|
set "prog=%_path%\%L_ITEM%"
|
||||||
if %ARCH% equ 64 (
|
if %ARCH% equ 64 (
|
||||||
if exist "%_path%\%L_ITEM:.=64.%" set "prog=%_path%\%L_ITEM:.=64.%"
|
if exist "%_path%\%L_ITEM:.=64.%" set "prog=%_path%\%L_ITEM:.=64.%"
|
||||||
)
|
)
|
||||||
if not exist "%prog%" goto ErrorProgramNotFound
|
if not exist "%prog%" goto ErrorProgramNotFound
|
||||||
|
|
||||||
|
rem Run
|
||||||
popd && pushd "%_path%"
|
popd && pushd "%_path%"
|
||||||
rem Run program and catch error(s)
|
|
||||||
if defined L_ELEV (
|
if defined L_ELEV (
|
||||||
call :DeQuote prog
|
goto LaunchProgramElev
|
||||||
call :DeQuote L_ARGS
|
|
||||||
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"
|
|
||||||
echo UAC.ShellExecute "!prog!", "!L_ARGS!", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
|
|
||||||
"%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown
|
|
||||||
) else (
|
) else (
|
||||||
if defined L_WAIT (set "wait=/wait")
|
goto LaunchProgramUser
|
||||||
start "" %wait% "%prog%" %L_ARGS% || goto ErrorUnknown
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
:LaunchProgramElev
|
||||||
|
rem Prep
|
||||||
|
call :DeQuote prog
|
||||||
|
call :DeQuote L_ARGS
|
||||||
|
|
||||||
|
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"
|
||||||
|
echo UAC.ShellExecute "%prog%", "%L_ARGS%", "", "runas", 1 >> "%bin%\tmp\Elevate.vbs"
|
||||||
|
|
||||||
|
rem Run (via VB script)
|
||||||
|
"%systemroot%\System32\cscript.exe" //nologo "%bin%\tmp\Elevate.vbs" || goto ErrorUnknown
|
||||||
|
goto Exit
|
||||||
|
|
||||||
|
:LaunchProgramUser
|
||||||
|
rem Prep
|
||||||
|
if defined L_WAIT (set "wait=/wait")
|
||||||
|
|
||||||
|
rem Run
|
||||||
|
start "" %wait% "%prog%" %L_ARGS% || goto ErrorUnknown
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
:LaunchPSScript
|
:LaunchPSScript
|
||||||
rem Test L_PATH and set %_path%
|
rem Prep
|
||||||
rem NOTE: This should always result in path=%bin%\Scripts. Exceptions are unsupported.
|
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
||||||
call :TestPath || goto ErrorProgramNotFound
|
|
||||||
rem Set args
|
|
||||||
set "script=%_path%\%L_ITEM%"
|
set "script=%_path%\%L_ITEM%"
|
||||||
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
|
set "ps_args=-ExecutionPolicy Bypass -NoProfile"
|
||||||
if not exist "%script%" goto ErrorScriptNotFound
|
if not exist "%script%" goto ErrorScriptNotFound
|
||||||
|
|
@ -233,9 +270,8 @@ if defined L_ELEV (
|
||||||
goto Exit
|
goto Exit
|
||||||
|
|
||||||
:LaunchPyScript
|
:LaunchPyScript
|
||||||
rem Test L_PATH and set %_path%
|
rem Prep
|
||||||
rem NOTE: This should always result in path=%bin%\Scripts. Exceptions are unsupported.
|
call :ExtractOrFindPath || goto ErrorProgramNotFound
|
||||||
call :TestPath || goto ErrorProgramNotFound
|
|
||||||
rem Set args
|
rem Set args
|
||||||
set "script=%_path%\%L_ITEM%"
|
set "script=%_path%\%L_ITEM%"
|
||||||
if not exist "%script%" goto ErrorScriptNotFound
|
if not exist "%script%" goto ErrorScriptNotFound
|
||||||
|
|
@ -347,12 +383,12 @@ if not "%_tmp%" == "%_tmp:*\=%" (goto GetBasenameInner)
|
||||||
set "%1=%_tmp%"
|
set "%1=%_tmp%"
|
||||||
@exit /b 0
|
@exit /b 0
|
||||||
|
|
||||||
:TestPath
|
:ExtractOrFindPath
|
||||||
rem Test L_PATH in the following order:
|
rem Test L_PATH in the following order:
|
||||||
rem 1: %cbin%\L_PATH.7z (which will be extracted to %bin%\L_PATH)
|
rem 1: %cbin%\L_PATH.7z (which will be extracted to %bin%\L_PATH)
|
||||||
rem 2: %bin%\L_PATH
|
rem 2: %bin%\L_PATH
|
||||||
rem 3. %L_PATH% (i.e. treat L_PATH as an absolute path)
|
rem 3. %L_PATH% (i.e. treat L_PATH as an absolute path)
|
||||||
rem NOTE: This function should be called as 'call :TestPath || goto ErrorProgramNotFound' to catch invalid paths.
|
rem NOTE: This function should be called as 'call :ExtractOrFindPath || goto ErrorProgramNotFound' to catch invalid paths.
|
||||||
set _path=
|
set _path=
|
||||||
if exist "%cbin%\%L_PATH%.7z" (
|
if exist "%cbin%\%L_PATH%.7z" (
|
||||||
call :ExtractCBin
|
call :ExtractCBin
|
||||||
|
|
@ -376,6 +412,11 @@ echo.
|
||||||
echo ERROR: ".bin" folder not found.
|
echo ERROR: ".bin" folder not found.
|
||||||
goto Abort
|
goto Abort
|
||||||
|
|
||||||
|
:ErrorODTSourceNotFound
|
||||||
|
echo.
|
||||||
|
echo ERROR: Office Deployment Tool source not found.
|
||||||
|
goto Abort
|
||||||
|
|
||||||
:ErrorOfficeSourceNotFound
|
:ErrorOfficeSourceNotFound
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: Office source "%L_ITEM%" not found.
|
echo ERROR: Office source "%L_ITEM%" not found.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue