@echo title TNG Mesh Installer :: Updated 2024-05-14 set batchlog=c:\irnh\schtask_log.txt echo F Mesh Installer started @ %date% %time% >> %batchlog% goto admincheck :: echo passing arguments if theres any! >> %batchlog% REM if "%~1"=="install" ( REM echo install was passed >> %batchlog% REM goto admincheck REM ) REM if "%~1"=="uninstall" ( REM echo uninstall was passed >> %batchlog% REM goto admincheck REM ) REM if "%~1"=="menu" goto admincheck rem echo none were passed! >> %batchlog% :admincheck REM admin check made mandatory net config server >> nul if %errorlevel% neq 0 ( echo User not running with elevated rights %date% %time% >> %batchlog% echo You're not running as admin rights, you twat XD echo Press any key to exit pause >> nul echo L quitting installer at %date% %time% >> %batchlog% goto :eof ) if %errorlevel% equ 0 ( echo admin rights detected >> %batchlog% if "%~1"=="" { echo %~1 was passed >> %batchlog% goto menu )else goto %~1 goto menu ) :menu choice /c AR /m "Add or Remove?" if %errorlevel% equ 1 ( echo user chose install/add >> %batchlog% goto install ) if %errorlevel% equ 2 ( echo user chose uninstall/remove >> %batchlog% goto uninstall ) :install sc query "Mesh Agent" if %errorlevel% neq 0 ( echo Mesh Agent was not detected >> %batchlog% :: start %cd%\meshagent64-TNG_Managed.exe -fullinstall if "%~2"=="tskoff" ( echo script is likely running via group policy as task disable was passed. disabling installer task if the installer ran successfully @ %date% %time% >> %batchlog% schtasks.exe /Change /TN "NHMeshInstallTask" /Disable ) if "%~2"=="wks" ( echo Installing WKS Agent... start %cd%\meshagent64-NH-WKS.exe -fullinstall ) if "%~2"=="srv"( echo Installing Server Agent... start %cd%\meshagent64-NH-Servers.exe -fullinstall echo L quitting installer at %date% %time% >> %batchlog% goto :eof ) if %errorlevel% equ 0 ( echo Mesh Agent is already installed >> %batchlog% echo Mesh Agent is already installed echo Checking if started and starting if not started... >> %batchlog% sc start "Mesh Agent" if %errorlevel% equ 1056 ( echo Agent is already started >> %batchlog% rem color a echo Agent is already started ) if "%~2"=="tskoff" ( echo script is likely running via group policy as task disable was passed. disabling install task as mesh is installed on %computername% @ %date% %time% >> %batchlog% schtasks.exe /Change /TN "NHMeshInstallTask" /Disable ) rem color a echo Quitting installer in 5 secs timeout 5 echo L quitting installer at %date% %time% >> %batchlog% goto :eof ) :uninstall sc query "Mesh Agent" if %errorlevel% equ 0 ( echo Mesh Agent was detected >> %batchlog% "%programfiles%\Mesh Agent\MeshAgent.exe -fulluninstall" if %errorlevel% neq 0 ( color c echo Something happened - check the log %batchlog% for more info :p pause echo L quitting installer at %date% %time% >> %batchlog% goto :eof ) if %errorlevel% equ 0 ( color a echo Agent was successfully uninstalled >> %batchlog% echo Agent was uninstalled successfully pause echo L quitting installer at %date% %time% >> %batchlog% goto :eof ) ) if %errorlevel% neq 0 ( echo Mesh Agent is already uninstalled >> %batchlog% echo Mesh Agent is already uninstalled pause echo L quitting installer at %date% %time% >> %batchlog% )