Home All Groups Group Topic Archive Search About

Script not work with server 2003



Author
8 Aug 2005 3:32 PM
Mohamed Abd El-Raheem
Why the following script not working with Windows server 2003 although it
run with Windows 2000.
When I run the script I get the error code"80041010".
The Script is for enumerating Installed software.
The script as follows:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\TEMP\Installed-software.txt",
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

msgbox ("done")

Author
8 Aug 2005 4:07 PM
J Ford
I found this comment by "torgeir, Microsoft MVP Scripting and WMI"

On Windows 2003 the Win32_Product class isn't installed by default.
You can install it with Add/Remove Windows Component. Look for the
"WMI Windows Installer Provider" component under "Management and
Monitoring Tools".

http://www.codecomments.com/archive305-2005-5-506861.html


Show quote
"Mohamed Abd El-Raheem" wrote:

> Why the following script not working with Windows server 2003 although it
> run with Windows 2000.
> When I run the script I get the error code"80041010".
> The Script is for enumerating Installed software.
> The script as follows:
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.CreateTextFile("C:\TEMP\Installed-software.txt",
> 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
>
> msgbox ("done")
>
>
>
Author
8 Aug 2005 4:08 PM
Torgeir Bakken (MVP)
Mohamed Abd El-Raheem wrote:

Show quote
> Why the following script not working with Windows server 2003 although it
> run with Windows 2000.
> When I run the script I get the error code"80041010".
> The Script is for enumerating Installed software.
> The script as follows:
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.CreateTextFile("C:\TEMP\Installed-software.txt",
> True)
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
> (snip)
Hi,

On Windows 2003 the Win32_Product class isn't installed by default.
You can install it with Add/Remove Windows Component. Look for the
"WMI Windows Installer Provider" component under "Management and
Monitoring Tools".



--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

AddThis Social Bookmark Button