Application User Scripts
Delete SoftwareInstall Software on the Local Computer
Install Software on a Remote Computer
List the Codec Files on a Computer
List Installed or Advertised Components and Applications
List Information About the Binary Files Used by an Application
List Installed Software
List Installed Software Features
List Microsoft Product IDs
Upgrade Software
You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.
Delete Software
Uninstalls a hypothetical software program (Personnel database) installed using Windows Installer.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSoftware = objWMIService.ExecQuery _ ("Select * from Win32_Product Where Name = 'Personnel database'") For Each objSoftware in colSoftware objSoftware.Uninstall() Next
Install Software on the Local Computer
Installs a hypothetical software program (using a Windows Installer package) on a local computer.
Const ALL_USERS = True Set objService = GetObject("winmgmts:") Set objSoftware = objService.Get("Win32_Product") errReturn = objSoftware.Install("c:\scripts\database.msi", , ALL_USERS)
Install Software on a Remote Computer
Installs a hypothetical software program (using a Windows Installer package) on a remote computer. Requires delegation for the computer and user accounts involved in the procedure.
Const wbemImpersonationLevelDelegate = 4 Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator") Set objConnection = objwbemLocator.ConnectServer _ ("WebServer", "root\cimv2", "fabrikam\administrator", _ "password", , "kerberos:WebServer") objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate Set objSoftware = objConnection.Get("Win32_Product") errReturn = objSoftware.Install("\\atl-dc-02\scripts\1561_lab.msi",,True)
List the Codec Files on a Computer
Uses WMI to return information about all the audio and video codec files installed on a computer.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_CodecFile") For Each objItem in colItems Wscript.Echo "Access Mask: " & objItem.AccessMask Wscript.Echo "Archive: " & objItem.Archive Wscript.Echo "Caption: " & objItem.Caption strCreationDate = WMIDateStringToDate(objItem.CreationDate) Wscript.Echo "Creation Date: " & strCreationdate Wscript.Echo "Drive: " & objItem.Drive Wscript.Echo "Eight Dot Three File Name: " & _ objItem.EightDotThreeFileName Wscript.Echo "Extension: " & objItem.Extension Wscript.Echo "File Name: " & objItem.FileName Wscript.Echo "File Size: " & objItem.FileSize Wscript.Echo "File Type: " & objItem.FileType Wscript.Echo "File System Name: " & objItem.FSName Wscript.Echo "Group: " & objItem.Group Wscript.Echo "Hidden: " & objItem.Hidden strInstallDate = WMIDateStringToDate(objItem.InstallDate) Wscript.Echo "Last Accessed: " & strLastAccessed strLastModified = WMIDateStringToDate(objItem.LastModified) Wscript.Echo "Last Modified: " & strLastModified Wscript.Echo "Manufacturer: " & objItem.Manufacturer Wscript.Echo "Name: " & objItem.Name Wscript.Echo "Path: " & objItem.Path Wscript.Echo "Version: " & objItem.Version Next Function WMIDateStringToDate(dtmDate) WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _ Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _ & " " & Mid (dtmDate, 9, 2) & ":" & _ Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate, _ 13, 2)) End Function
List Installed or Advertised Components and Applications
Returns a list of all Windows Installer components installed or advertised on a computer.
On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * from Win32_ApplicationService") For Each objItem in colItems Wscript.Echo "Name: " & objItem.Name Wscript.Echo "Start Mode: " & objItem.StartMode Wscript.Echo Next
List Information About the Binary Files Used by an Application
Returns the name and product code of binary information (such as bitmaps, icons, executable files, and so on) used by a Windows Installer application.
On Error Resume Next strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Binary") For Each objItem in colItems Wscript.Echo "Name: " & objItem.Name Wscript.Echo "Product Code: " & objItem.ProductCode Wscript.Echo Next
List Installed Software
Returns a list of software that was installed on a computer using Windows Installer. This information is then written to a text file.
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.CreateTextFile("c:\scripts\software.tsv", True) strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSoftware = objWMIService.ExecQuery _ ("Select * from Win32_Product") objTextFile.WriteLine "Caption" & vbtab & _ "Description" & vbtab & "Identifying Number" & vbtab & _ "Install Date" & vbtab & "Install Location" & vbtab & _ "Install State" & vbtab & "Name" & vbtab & _ "Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _ & "Version" For Each objSoftware in colSoftware objTextFile.WriteLine objSoftware.Caption & vbtab & _ objSoftware.Description & vbtab & _ objSoftware.IdentifyingNumber & vbtab & _ objSoftware.InstallDate2 & vbtab & _ objSoftware.InstallLocation & vbtab & _ objSoftware.InstallState & vbtab & _ objSoftware.Name & vbtab & _ objSoftware.PackageCache & vbtab & _ objSoftware.SKUNumber & vbtab & _ objSoftware.Vendor & vbtab & _ objSoftware.Version Next objTextFile.Close
List Installed Software Features
Returns a list of features for all the software installed on a computer using Windows Installer.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFeatures = objWMIService.ExecQuery _ ("Select * from Win32_SoftwareFeature") For Each objFeature in colfeatures Wscript.Echo "Accesses: " & objFeature.Accesses Wscript.Echo "Attributes: " & objFeature.Attributes Wscript.Echo "Caption: " & objFeature.Caption Wscript.Echo "Description: " & objFeature.Description Wscript.Echo "Identifying Number: " & objFeature.IdentifyingNumber Wscript.Echo "Install Date: " & objFeature.InstallDate Wscript.Echo "Install State: " & objFeature.InstallState Wscript.Echo "Last Use: " & objFeature.LastUse Wscript.Echo "Name: " & objFeature.Name Wscript.Echo "Product Name: " & objFeature.ProductName Wscript.Echo "Vendor: " & objFeature.Vendor Wscript.Echo "Version: " & objFeature.Version Next
List Microsoft Product IDs
Returns the Product IDs for Microsoft software products installed on a computer.
Set objMSInfo = CreateObject("MsPIDinfo.MsPID") colMSApps = objMSInfo.GetPIDInfo() For Each strApp in colMSApps Wscript.Echo strApp Next
Upgrade Software
Upgrades a hypothetical software program installed using Windows Installer.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSoftware = objWMIService.ExecQuery _ ("Select * from Win32__Product Where Name = 'Personnel Database'") For Each objSoftware in colSoftware errReturn = objSoftware.Upgrade("c:\scripts\database2.msi") Next