Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #cs ----------------------------------------------------------------------------
- AutoIt Version: 3.3.6.1
- Author: Jason S.
- Script Function:
- Help automate the process of migrating workstations to new Spark IM program version.
- Target Platform(s): Windows 2000, Windows XP, Windows 7
- Script will perform the following:
- - Kill current Spark process (if running)
- - Backup chat transcript logs to safe location
- - Initialize the silent uninstaller for current installed Spark program
- - Download and initialize the installation of new Spark program
- #ce ----------------------------------------------------------------------------
- ;;;; Start Script ;;;;
- ; we need permissions to modify programs and write to directories
- #RequireAdmin
- ; Declare includes
- #include <Debug.au3>
- ; Declare constants
- $SPARK_PROCESS = "Spark.exe" ; spark process name
- ; Backup settings
- $BACKUP_LOC = "C:\Spark_Backup" ; backup location
- ; required for network backup instead of local backup
- $NET_BACKUP = False ; set to TRUE to save backup on network instead of local disk
- $BACKUP_USER = "someUser" ; network account with write permissions in $BACKUP_LOC directory
- $BACKUP_PASS = "somePassword" ; network account password
- ; URL to fetch latest spark from - REQUIRES Client Control plugin installed on Openfire Server
- $OPENFIRE_SERVER = "http://xmpp.YOURSERVER.net"
- $OPENFIRE_ADMIN_PORT = "9090"
- $SPARK_CLIENTCONTROL = ":" & $OPENFIRE_ADMIN_PORT & "/plugins/clientcontrol/getspark?os=windows"
- $SPARK_DOWNLOAD = $OPENFIRE_SERVER & $SPARK_CLIENTCONTROL
- $SETUPTITLE = "Setup - Spark 2.7.1-62713-jsc" ; change me to your version ie: "Setup - Spark 2.6.3"
- ; Supported OS Versions
- ; "WIN_7", "WIN_XP", "WIN_2000"
- $OS = @OSVersion
- ; Setup Debug Out
- _DebugSetup("Runtime Log");
- If ($NET_BACKUP) Then
- ; Setup network share credentials
- If (Run("net use " & $BACKUP_LOC & " /user:" & $BACKUP_USER & " " & $BACKUP_PASS) == 0) Then
- _DebugOut("ERROR - Cannot set network share credentials!")
- EndIf
- EndIf
- ; Determine actions
- Switch $OS
- Case "WIN_XP"
- winXP()
- Case "WIN_2000"
- win2000()
- Case "WIN_7"
- win7()
- Case Else
- _DebugOut("ERROR - Unsupported OS Detected!" & @CRLF & "Detected: " & $OS)
- EndSwitch
- ;;;; End Script ;;;;
- ;; Function to handle Windows XP
- Func winXP()
- ; Kill Spark running process
- _DebugOut("Killing '" & $SPARK_PROCESS & "' process(s)")
- Kill_Loop()
- ; Backup Spark user account
- _DebugOut("Backup Spark User directory")
- $ok = DirCopy(@AppDataDir & "\Spark\user", $BACKUP_LOC, 0)
- If ($ok <> 1) Then
- _DebugOut("Failed to backup Spark User directory")
- Else
- _DebugOut("Backup Spark User directory Success!")
- EndIf
- ; Uninstall Spark
- _DebugOut("Uninstalling existing Spark")
- $ok = Run(@ProgramFilesDir & "\Spark\uninstall.exe -q")
- If ($ok <> 0) Then
- _DebugOut("Spark Uninstalled Successfully")
- Else
- _DebugOut("Uninstall of Spark Failed")
- _DebugOut("Please uninstall manually")
- Run(@ComSpec & " /c " & @SystemDir & "\appwiz.cpl", "", @SW_HIDE)
- WinWait("Add or Remove Programs")
- While (WinExists("Add or Remove Programs"))
- Sleep(1000)
- WEnd
- EndIf
- ; Kill Spark left-over files
- _DebugOut("Killing old Spark files")
- DirRemove(@AppDataDir & "\Spark", 1)
- _DebugOut("Old Spark is now cleaned up")
- ; Download new Spark Version
- _DebugOut("Starting Spark download")
- InetGet($SPARK_DOWNLOAD, @TempDir & "\spark.exe")
- _DebugOut("Spark download complete!")
- ; Start Spark installer
- _DebugOut("Starting Spark installation")
- Run(@TempDir & "\spark.exe")
- WinWait($SETUPTITLE)
- ; Wait while we click "Next" a few times
- While (WinExists($SETUPTITLE))
- Sleep(1000)
- WEnd
- ; Setup Spark to run at computer login
- _DebugOut("Creating shortcut in startup directory")
- FileCreateShortcut(@ProgramFilesDir & "\Spark\Spark.exe", @ProgramsCommonDir & "\Startup\Spark.lnk", @ProgramFilesDir & "\Spark\Spark.exe")
- _DebugOut("Shortcut created!")
- Sleep(1000)
- _DebugOut("Migration Complete!")
- EndFunc
- ;; Function to handle Windows 2000
- Func win2000()
- ; for now, just do XP's path since they are the same
- ; modify here if you want to diverge script logic based on OS version
- winXP()
- EndFunc
- ;; Function to handle Windows 7
- Func win7()
- ; for now, just do XP's path since they are the same
- ; modify here if you want to diverge script logic based on OS version
- winXP()
- EndFunc
- ;; Loops and kills all processes of the specified name
- Func Kill_Loop()
- While (ProcessExists($SPARK_PROCESS) <> 0)
- _DebugOut("Found '" & $SPARK_PROCESS & "' process running!")
- Kill_Process($SPARK_PROCESS)
- Sleep(500)
- WEnd
- _DebugOut("Killed '" & $SPARK_PROCESS & "' process!")
- EndFunc
- ;; Kills specified process
- Func Kill_Process($sPID)
- If IsString($sPID) Then $sPID = ProcessExists($sPID)
- If Not $sPID Then Return SetError(1, 0, 0)
- Return Run(@ComSpec & " /c taskkill /F /PID " & $sPID & " /T", @SystemDir, @SW_HIDE)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement