powered by Jive Software

Install Spark Batch Script for Windows Users

Hello all,

Thanks to everyone, particularly the developers, for keeping this project alive!

I wanted to try and give back a little by providing the script I wrote up to install Spark 2.9.x.

Pre-requisites:

  • This install script must be in the same network share or folder as the .exe installer and the .exe installer must match line 25 in my script (right now it’s the default name of spark_2_9_0-with-jre.exe).
  • You must create a subfolder called AppData_Roaming_Spark in the folder with the InstallSpark.cmd file
  • I included the spark.properties file as designed without username= or password with the encrypted password in the file. This will automatically be inserted by the script from the previous spark.properties. If this is a fresh install, the Spark software will automatically add those lines once the user logs in.
  • I also included Spark_2_9_0.txt in the folder so the system knows that version is installed and not to overwrite it twice.
  • I included a security folder from my profile after adding my self-signed certificates. This way users won’t be prompted with the message about trusting the certificate.
  • I also removed reversi, tictactoe, and translator jar files (lines 38 to 47). You may also do this via the spark.properties file but I do this to be sure they aren’t available to the users. Feel free to remove these lines or comment them out.
  • I also copy some .wav files over but you can also comment these lines out. (lines 49 to 52)
  • Finally, if you want to make this installer quiet, just add a space after the .exe and -q to the end of line 25 (line 25 is: %~dp0spark_2_9_0-with-jre.exe) AND be sure to remove any “pause” lines (13, 26, 82).

InstallSpark.cmd:

@ECHO OFF
set "PFiles=C:\Program Files"
cls
echo ***************************
echo ***   SPARK INSTALLER   ***
echo ***    BY RYAN BLAKE    ***
echo ***************************
echo.
echo This will install Spark version 2.9.0 on your computer
echo.
echo Click run if prompted and install Spark
echo.
pause
echo Killing Spark if it is running...
taskkill /F /IM spark.exe
echo If you see an error above, it is safe to ignore...
echo ...just means Spark was not running.
echo.
echo During install, uncheck add to Quick Launch
echo.
echo Once Spark is completely installed...
echo ...do not select Run Spark at the end
echo.
echo Once finished...
%~dp0spark_2_9_0-with-jre.exe
pause
echo.
taskkill /F /IM spark_2_9_0-with-jre.exe
tskill spark_2_9_0-with-jre.exe
echo.
if exist "C:\Program Files (x86)\Spark" (
	set "PFiles=C:\Program Files (x86)"
	echo Looks like you are running Windows 64-bit
	echo ...making adjustments...
	echo.
)
echo.
cd /d %PFiles%\Spark\plugins
if exist "%PFiles%\Spark\plugins\reversi.jar" (
	del /F /Q reversi.jar
)
if exist "%PFiles%\Spark\plugins\tictactoe.jar" (
	del /F /Q tictactoe.jar
)
if exist "%PFiles%\Spark\plugins\translator.jar" (
	del /F /Q translator.jar
)
echo.
cd /d "%PFiles%\Spark\resources\sounds\"
if not exist "HostPhoneRing.wav" (
	xcopy /H "%~dp0WebexSounds\*"
)
echo.
echo Setting up all existing user profiles and migrating credentials
FOR /f "tokens=*" %%G in ('dir /b /a:d-s-l "%SystemDrive%\Users"') DO (
  IF /I NOT "%%G"=="Public" (
    IF NOT EXIST "%SystemDrive%\Users\%%G\AppData\Roaming\Spark" ( 
		md "%SystemDrive%\Users\%%G\AppData\Roaming\Spark"
	)
	IF EXIST "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties" (
		IF NOT EXIST "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties.old" (
			move "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties" "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties.old"
		)
	)
	IF NOT EXIST "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\Spark_2_9_0.txt" (
		xcopy.exe "%~dp0AppData_Roaming_Spark\*" "%SystemDrive%\Users\%%G\AppData\Roaming\Spark" /E /C /I /Q /H /R /K /Y
	
		IF EXIST "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties.old" (
			findstr username "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties.old" >> "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties"
			findstr password "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties.old" >> "%SystemDrive%\Users\%%G\AppData\Roaming\Spark\spark.properties"
		)
	)
  )
)
echo.
echo Installation Complete.
echo.
echo You may now load Spark
echo.
echo Thanks!
echo.
pause
2 Likes

Hi. thanks for ideea.
i make my own script but something is not right. I have client 2.8.3 and when script install spark_2_9_4.exe with -q, install that version to local appdata along side 2.8.3 that are on program files. Now I have 2 spark installed: 2.8.3 on program files and 2.9.4 to local appdata user.
My script looks like:

@echo off
:: ----------------------- script update Spark v2 by DC--------------------------------
set NEW_VER=2.9.4.0
set numekit="spark_2_9_4.exe"
set APP_VER=0
set calesrv=\\sharelocation\spark

:: verify if exist folder for save log
if exist %calesrv%\computers\%computername% GOTO URMATOR
mkdir %calesrv%\computers\%computername%

:URMATOR
:: verify version of Spark
for /f "usebackq tokens=2 delims==" %%v in (`WMIC Path CIM_DataFile WHERE "Drive='%SystemDrive%' AND Path = '\\Program Files (x86)\\Spark\\' AND FileName='spark' AND Extension = 'exe'" get Version /value ^| find "="`) do set APP_VER=%%v

:: if version is new, skip
IF %APP_VER%==%NEW_VER% GOTO MES1

:: check if Spark is installed or not
IF %APP_VER%==0 (echo %date% %time% - Spark IS NOT INSTALLED! >> %calesrv%\computers\%computername%\log.txt) else (echo %date% %time% - Spark is on old version=%APP_VER%, begin install ... >> %calesrv%\computers\%computername%\log.txt)

:: if Spark run, stop it
tasklist /fi "imagename eq Spark.exe" |find ":" > nul
if errorlevel 1 taskkill /f /im "Spark.exe"
timeout 5 > NUL

:: copy properties and kit and run it
IF %APP_VER%==0 GOTO END
xcopy /Y %appdata%\Spark\spark.properties %calesrv%\computers\%computername%\
xcopy /Y %calesrv%\%numekit% %windir%\temp\
%windr%\temp\%numekit% -q
echo %date% %time% --- Installe has finished with ver. %NEW_VER% --- >> %calesrv%\computers\%computername%\log.txt

GOTO END

:MES1

echo %date% %time% - Spark %ver% is already installed with version %APP_VER% >> %calesrv%\computers\%computername%\log.txt



:END