• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

WMI VBSCRIPT error 0x80041001

A
#1
The following script runs fine on SBS2003 and Vista Business. The script fails with error code 0x80041001 on XP Pro 64-bit, leading me to believe the problem is either a 64-bit compatibilty issue, a corrupted WMI on the XP machine, or a VBScript implementation issue. All machines have the latest service packs and hotfixes installed.

--------------------------------------------------------------------------------

WScript.Echo "Using Win32_LogicalDisk object"
Set LDiskSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_LogicalDisk")
for each LDisk in LDiskSet
if LDisk.DriveType=3 then
WScript.Echo "-------------------------------------------------------------------------"
if isnull(LDisk.DeviceID) then
WScript.Echo "DeviceID is NULL"
else
WScript.Echo "DeviceID: " + LDisk.DeviceID
end if
if isnull(LDisk.Caption) then
WScript.Echo "Caption is NULL"
else
WScript.Echo " Caption : " + LDisk.Caption
end if
if isnull(LDisk.FileSystem) then
WScript.Echo "FileSystem is NULL"
else
WScript.Echo " FileSystem: " + LDisk.FileSystem
end if
if isnull(LDisk.Size) then
WScript.Echo "Size is NULL"
else
WScript.Echo " Size: " + formatnumber(LDisk.Size/(1024*1024),0) + " MB"
end if
if isnull(LDisk.VolumeName) then
WScript.Echo "VolumeName is NULL"
else
WScript.Echo " VolumeName : " + LDisk.VolumeName
end if
if isnull(LDisk.Name ) then
WScript.Echo "Name is NULL"
else
WScript.Echo " Name : " + LDisk.Name
end if

if isnull(LDisk.SystemName ) then
WScript.Echo "SystemName is NULL"
else
WScript.Echo " SystemName : " + LDisk.SystemName
end if
end if
Next

--------------------------------------------------------------------------------

Can you tell me how to fix the problem?

--
Axel Larson
..
 

My Computer

R

Richard Mueller [MVP]

#2
Axel wrote:

The following script runs fine on SBS2003 and Vista Business. The script
fails with error code 0x80041001 on XP Pro 64-bit, leading me to believe
the problem is either a 64-bit compatibilty issue, a corrupted WMI on the XP
machine, or a VBScript implementation issue. All machines have the latest
service packs and hotfixes installed.

--------------------------------------------------------------------------------

WScript.Echo "Using Win32_LogicalDisk object"
Set LDiskSet =
GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_LogicalDisk")
for each LDisk in LDiskSet
if LDisk.DriveType=3 then
WScript.Echo
"-------------------------------------------------------------------------"
if isnull(LDisk.DeviceID) then
WScript.Echo "DeviceID is NULL"
else
WScript.Echo "DeviceID: " + LDisk.DeviceID
end if
if isnull(LDisk.Caption) then
WScript.Echo "Caption is NULL"
else
WScript.Echo " Caption : " + LDisk.Caption
end if
if isnull(LDisk.FileSystem) then
WScript.Echo "FileSystem is NULL"
else
WScript.Echo " FileSystem: " + LDisk.FileSystem
end if
if isnull(LDisk.Size) then
WScript.Echo "Size is NULL"
else
WScript.Echo " Size: " + formatnumber(LDisk.Size/(1024*1024),0) + " MB"
end if
if isnull(LDisk.VolumeName) then
WScript.Echo "VolumeName is NULL"
else
WScript.Echo " VolumeName : " + LDisk.VolumeName
end if
if isnull(LDisk.Name ) then
WScript.Echo "Name is NULL"
else
WScript.Echo " Name : " + LDisk.Name
end if

if isnull(LDisk.SystemName ) then
WScript.Echo "SystemName is NULL"
else
WScript.Echo " SystemName : " + LDisk.SystemName
end if
end if
Next

--------------------------------------------------------------------------------

Can you tell me how to fix the problem?

============
After a quick glance the script looks OK, so WMI may be corrupt. The
Win32_LogicalDisk class is supported by all OS's. What line (and statement)
raises the error? I have discovered the following:

1. You cannot connect to computer running XP Home.
2. An NT computer cannot connect to OS later than W2k.
3. A W2k3 computer cannot connect to Win9x.
4. To connect to W2k Server SP4 you must set impersonation level to
Impersonate.
5. W2k computers must have SP2 to connect to XP or above.
6. W2k3 can only connect to Win9x and NT if credentials supplied.
7. To connect to XP or W2k3 you must set authentication level to Pkt.

For best results in all situations, I use:

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

For troubleshooting I use the following links:

http://www.microsoft.com/technet/scriptcenter/topics/help/wmi.mspx

http://support.microsoft.com/kb/875605

http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx

You can rebuild the WMI repository, if you have XP SP2, with the command:

rundll32 wbemupgd, UpgradeRepository

The following commands reinstall WMI in the registry:

winmgmt /clearadap
winmgmt /kill
winmgmt /unregserver
winmgmt /regserver
winmgmt /resyncperf
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)