Not quite sure how I wound up getting all these questions, but I've been asked a few times recently how one might go about performing an "Unattended Installation" or a "Group Policy Network Deployment" for OnTime Windows, so I spent a few hours this afternoon looking into it.
I recently posted an FAQ on this subject, but I felt I wasn't being technical enough, and here's what I came up with:
Set wshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
isUpgrade = True ' Are we performing an Upgrade?
tempDir = wshShell.ExpandEnvironmentStrings("%TEMP%")
tempPath = tempDir & "\OnTimeInstaller.exe"
installerPath = "\\server\share\path\OnTime2007WindowsSetup.exe"
installPath = "C:\Program Files\Axosoft\OnTime 2007\"
configPath = "C:\TEMP\OnTime.config"
currentUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")
userConfigPath = "C:\Documents and Settings\" & currentUserName & _
"\Local Settings\Application Data\Axosoft\OnTime Windows\7.0\"
' ARE WE UPGRADING, IF SO, UNINSTALL
If(isUpgrade) Then
If(fso.FileExists(installPath & "OnTime Windows\Uninstall.exe")) Then
wshShell.Run """" & installPath & "OnTime Windows\Uninstall.exe "" /S _?=" & _
installPath & "OnTime Windows", 10, True
' The uninstaller returns a bit -too- quickly, we have to wait
WScript.Sleep 4000
fso.DeleteFile installpath & "OnTime Windows\Uninstall.exe"
fso.DeleteFolder installPath & "OnTime Windows"
End If
End If
' CHECK IF ONTIME IS ALREADY INSTALLED
' THIS CHECK IS ERROR PRONE!
If(Not fso.FolderExists(installPath & "OnTime Windows")) Then
If(Not fso.FileExists(installerPath)) Then
MsgBox "BAD BAD BAD"
Else
fso.CopyFile installerPath, tempPath, True
wshShell.Run tempPath & " /S /D=" & installPath, 10, True
End If
End If
' CHECK IF OnTime.config exists for User
If(Not fso.FileExists(userConfigPath & "OnTime.config")) Then
If(Not fso.FolderExists(userConfigPath)) Then
p1 = fso.GetParentFolderName(userConfigPath)
p2 = fso.GetParentFolderName(p1)
if(Not fso.FolderExists(p2)) Then fso.CreateFolder(p2)
if(Not fso.FolderExists(p1)) Then fso.CreateFolder(p1)
if(Not fso.FolderExists(userConfigPath)) Then fso.CreateFolder(userConfigPath)
End If
fso.CopyFile configPath, userConfigPath
End If
Basically, the above code would reside in a .VBS file, and would be executed by either WScript.exe or CScript.exe during the User Login process --
The code is an example, and should be treated as such -- most of the code blocks are reusable in actual production scripts, but the entire script as a whole is not production ready.
A quick walk-thru of the code shows that we first initialize some variables, which can be stored anywhere, or hard-coded like the example script has them, we then have an 'isUpgrade' flag, which we check in the first 'block', and if true, we run the OnTime Windows Uninstaller, and then delete the Uninstaller and the OnTime Windows directory (this will leave the 'Axosoft' directory and any other contents -- such as SDK, VS.Net, etc).
We then check to see if the OnTime Windows directory exists, if it does not, we launch the OnTime Windows installer in "silent" mode, and we force the installation path with the "/D" flag -- this ensures that we are installing it in the same place as we uninstalled it from, etc ...
We then copy over a pre-made OnTime.config to the current users App Data for OnTime, building the necessary directory tree, if required.
So, how do we get this "OnTime.config" you ask? To get the "OnTime.config", you'll have to install OnTime for Windows on at least one workstation, launch it, and configure the database connectivity -- from there, you can find the OnTime.config in the Current Users "Local Settings\Application Data\Axosoft\OnTime Windows\7.0" directory tree.
And, for those of you who want to try this, here is some useful information about the installer we use:
OntimeWindowsSetup.exe Parameters:
/S -- Performs a "Silent" installation, preventing the UI from displaying
/D -- Override default Install Directory (ie; /D=C:\New\Path)
Uninstall.exe:
/S -- Performs a "Silent" uninstallation, preventing the UI from display
_? -- Override the default Install Directory, also prevents the Installer
from Copying itself to a temporary location and exiting immediately (useful for "WaitOnReturn")
This form of installation is not officially supported by Axosoft, however, the command-line parameters for the (Un)Installer
are supported.
If you've had a successful network deployment and would like to share your experience, or contribute any reusable code, please contact me and I will add it to this Blog Post.
Thank you,
David Higgins