Batch deploy of Microsoft Silverlight

There are few ways of deploying of Microsoft Silverlight, but for all of them you basically need an .msi installer, which Microsoft do not have.  Why do we need an .msi for ? The reason is simple – silent install, without user interaction.
You can push the installer by creating new Software Group Policy and apply it to the destination hosts or use a PSExec , tool widely used by probably all system administrators.

First of all we need to get an .msi installer. We will need to download a Silverlight installer (doh!) from here , to make things easier, save it into the folder we’ve just created on our desktop then open Command Prompt, browse to your silverlight folder and then use the command :

silverlight.exe /extract

Once extracted, you should notice a silverlight.7z archive, thats what we are looking for, you can delete other files.
Extract this 7z archive with 7zip and here you go, there it is, your Silverlight.msi

Now you can place the installer somewhere on your network share, lets say \\server\share$\silverlight then either create software group policy or use PSTools to push the installer on your desktops

the batch script will look like this:

@ECHO OFF

msiexec /i \\server\share$\silverlight\silverlight.msi /qn

BUT … there is a little problem when deploying Silverlight, if you already have Silverlight installed, it will need to be uninstalled first … imagine that if you have lets say 500 hosts to manage?

This VBS software uninstall script along with the PSTools does the job done pretty well.

For MSI installers (such this one), the uninstall vbs script looks like this:

Const ForAppending = 8

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\report.txt", ForAppending, True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Microsoft Silverlight'")

For Each objSoftware in colSoftware
objSoftware.Uninstall()
objTextFile.WriteLine(WshNetwork.ComputerName)
Next

for EXE installers

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Microsoft Silverlight'")

For Each objSoftware in colSoftware
    objSoftware.Uninstall()
Next

To automate the job, place both vbs scripts somewhere onto your network share, lets say \\server\share$\uninstallscript then add a simple batch to call the vbs, then use PSTools to call bellow batch.

@ECHO OFF
cscript "\\server\share$\uninstallscript\uninstallMSI.vbs"

You can also try to set the script as a logon script if you wish, I personally preferred to use PSTools along with a Task Scheduler on my laptop and set the script to kick in at midnight and get the stuff uninstalled while I’m away home sleeping.

Well, so much stuff about PSTools here, therefore the next post gonna be about it then.

 

Leave a Reply