One of the things we have started doing as part of our process is having a build script that creates our deployment package in an automated fashion. We then tied that into our build server so that from one click anyone could create the package. The issue is that we have several test environments and copying the setup.msi file to multiple servers and installing it is a time consuming pain. To streamline our deployment we created a vbscript (yes, it was painful) to remotely uninstall previous versions and then install the new version of the msi. Here is the script currently:
strComputer = "mytestserver"
Wscript.Echo "Getting WMI Object"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Wscript.Echo "Finding Previous versions"
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product Where Name = 'My First Setup Project'")
For Each objSoftware in colSoftware
Wscript.Echo "Uninstalling a previous version"
objSoftware.Uninstall()
Next
Wscript.Echo "Getting Software Object"
Set objSoftware = objWMIService.Get("Win32_Product")
Wscript.Echo "Installing"
errReturn = objSoftware.Install("c:\builds\MyFirstSetupProject.msi", "TARGETENV=DEVL",True)
Wscript.Echo "Install status: " & errReturn
In order for this to work the msi must be copied to the remote machine to work. I tried connecting to a central network share but it did not seem to work for me. The script needs a bit of work but now we can deploy to the environments we want updated in a couple of minutes instead of the 15-20 minutes it took us before.
Print | posted on Monday, January 18, 2010 4:41 PM