WizardKit/Copy WizardKit.cmd
Alan Mason 6fc04266d4 2017-11: Retroactive Updates
## MAJOR refactoring done ##

* All .cmd Command scripts
  * Brandind / Settings variables now set via .bin/Scripts/settings/main.py
  * Window titles now set using KIT_FULL_NAME

* All .py Python scripts
  * All ClientDir paths should now use KIT_SHORT_NAME
  * Long lines wrapped to better follow PEP8
  * String formatting now more consistant
  * Updated run_program() and popen_program() calls to use lists
    * (e.g. cmd = ['', '', '']; run_program(cmd))
    ** Should improve clarity IMO
  * Update window titles AFTER init_global_vars() so KIT_FULL_NAME can be used

* Branding / Settings
  * Support tech now configurable
    * (e.g. "Please let {tech} know and they'll look into it")
  * Timezone now configurable
  * Upload info can now be disabled/enabled in .bin/Scripts/settings/main.py

* CHKDSK
  * Combined read-only and fix scripts and added menu

* DISM
  * Combined ScanHealth and RestoreHealth scripts and added menu

* functions/common.py
  * BREAKING: run_program() and popen_program() no longer accept 'args' variable

* Misc
  * Removed Win7 NVMe launcher
    * Never used and Win7 is deprecated
  * Removed "DeviceRemover" and "Display Driver Uninstaller" launchers
    * Both cut too deep and were not useful
  * Removed Nirsoft utilities and Sysinternals Suite launchers
    * Too many tools unused.
    * Added .url links to the websites in case the tools are needed
  * Replaced WinDirStat with TreeSizeFree
  * Replaced Q-Dir launcher with XYplorer launcher
    * Q-Dir was running into issues on Windows 10
  * Removed C.IntRep, ESET, and MBAM launchers from "OSR & VR"
  * Removed JRT
    * Deprecated and discontinued by MBAM
  * Removed unsupported QuickBooks launchers (2014 and older)
  * Removed unsupported Office launchers (2010 and 2013\365)
  * Removed "Revo Uninstaller" launcher
  * Removed infrequently used tools from "Diagnostics"
    * Auslogics DiskDefrag
    * BatteryInfoView
    * BIOSCodes
    * GpuTest
    * HeavyLoad

* Bugfixes
  * major_exception() try-blocks should catch CTL+c again
    * Allows for manual script bailing
2017-11-17 01:02:24 -07:00

150 lines
4.1 KiB
Batchfile

:: Wizard Kit: Copy Kit ::
@echo off
:Init
setlocal EnableDelayedExpansion
title Wizard Kit: Tools Copier
color 1b
echo Initializing...
call :CheckFlags %*
call :FindBin
call :SetTitle Tools Copier
:SetVariables
rem Set variables using settings\main.py file
set "SETTINGS=%bin%\Scripts\settings\main.py"
for %%v in (ARCHIVE_PASSWORD KIT_NAME_FULL) do (
set "var=%%v"
for /f "tokens=* usebackq" %%f in (`findstr "!var!=" %SETTINGS%`) do (
set "_v=%%f"
set "_v=!_v:*'=!"
set "%%v=!_v:~0,-1!"
)
)
rem Set ARCH to 32 as a gross assumption and check for x86_64 status
set ARCH=32
if /i "%PROCESSOR_ARCHITECTURE%" == "AMD64" set "ARCH=64"
set "SEVEN_ZIP=%bin%\7-Zip\7za.exe"
set "CON=%bin%\ConEmu\ConEmu.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy.exe"
if %ARCH% equ 64 (
set "SEVEN_ZIP=%bin%\7-Zip\7za64.exe"
set "CON=%bin%\ConEmu\ConEmu64.exe"
set "FASTCOPY=%bin%\FastCopy\FastCopy64.exe"
)
set "fastcopy_args=/cmd=diff /no_ui /auto_close"
rem Set %client_dir%
call "%bin%\Scripts\init_client_dir.cmd"
pushd "%bin%\.."
set "source=%cd%"
popd
set "dest=%client_dir%\Tools"
:RelaunchInConEmu
if not defined IN_CONEMU (
if not defined L_NCMD (
set "con_args=-new_console:n"
rem If in DEBUG state then force ConEmu to stay open
if defined DEBUG (set "con_args=!con_args! -new_console:c")
set IN_CONEMU=True
start "" "%CON%" -run ""%~0" %*" !con_args! || goto ErrorUnknown
exit /b 0
)
)
:CopyBin
echo Copying .bin...
mkdir "%dest%\.bin" >nul 2>&1
attrib +h "%dest%\.bin"
set _sources="%bin%\7-Zip"
set _sources=%_sources% "%bin%\ConEmu"
set _sources=%_sources% "%bin%\FastCopy"
set _sources=%_sources% "%bin%\HWiNFO"
set _sources=%_sources% "%bin%\Python"
set _sources=%_sources% "%bin%\Scripts"
start "" /wait "%fastcopy%" %fastcopy_args% %_sources% /to="%dest%\.bin\"
:CopyCBin
echo Copying .cbin...
mkdir "%dest%\.cbin" >nul 2>&1
attrib +h "%dest%\.cbin"
start "" /wait "%fastcopy%" %fastcopy_args% %cbin%\* /to="%dest%\.cbin\"
:CopyMainData
echo Copying Main Kit...
set _sources="%source%\Data Transfers & DSR"
set _sources=%_sources% "%source%\Diagnostics"
set _sources=%_sources% "%source%\Drivers"
set _sources=%_sources% "%source%\Installers"
set _sources=%_sources% "%source%\Misc"
set _sources=%_sources% "%source%\OSR & VR"
set _sources=%_sources% "%source%\Uninstallers"
set _sources=%_sources% "%source%\Activate Windows.cmd"
set _sources=%_sources% "%source%\Enter SafeMode.cmd"
set _sources=%_sources% "%source%\Exit SafeMode.cmd"
set _sources=%_sources% "%source%\System Checklist.cmd"
set _sources=%_sources% "%source%\System Diagnostics.cmd"
set _sources=%_sources% "%source%\User Checklist.cmd"
start "" /wait "%fastcopy%" %fastcopy_args% /exclude="Snappy Driver Installer.cmd;*.exe" %_sources% /to="%dest%\"
start "" /wait "%fastcopy%" %fastcopy_args% "%source%\Installers\Extras\Office\Adobe Reader DC.exe" /to="%dest%\Installers\Extras\Office\"
:Ninite
echo Extracting Ninite installers...
"%SEVEN_ZIP%" x "%cbin%\_Ninite.7z" -aos -bso0 -bse0 -bsp0 -p%ARCHIVE_PASS% -o"%dest%\Installers\Extras" || goto Abort
:OpenFolder
start "" explorer "%dest%"
goto Exit
:: Functions ::
:CheckFlags
rem Loops through all arguments to check for accepted flags
set DEBUG=
for %%f in (%*) do (
if /i "%%f" == "/DEBUG" (@echo on & set "DEBUG=/DEBUG")
)
@exit /b 0
:FindBin
rem Checks the current directory and all parents for the ".bin" folder
rem NOTE: Has not been tested for UNC paths
set bin=
pushd "%~dp0"
:FindBinInner
if exist ".bin" (goto FindBinDone)
if "%~d0\" == "%cd%" (popd & @exit /b 1)
cd ..
goto FindBinInner
:FindBinDone
set "bin=%cd%\.bin"
set "cbin=%cd%\.cbin"
popd
@exit /b 0
:SetTitle
rem Sets title using KIT_NAME_FULL from settings\main.py
set "window_title=%*"
if not defined window_title set "window_title=Launcher"
set "window_title=%KIT_NAME_FULL%: %window_title%"
title %window_title%
@exit /b 0
:: Errors ::
:ErrorNoBin
echo.
echo ERROR: ".bin" folder not found.
goto Abort
:Abort
color 4e
echo Aborted.
echo Press any key to exit...
pause>nul
color
rem Set errorlevel to 1 by calling color incorrectly
color 00
goto Exit
:: Cleanup and exit ::
:Exit
endlocal
exit /b %errorlevel%