I want to run the script from any computer and go to the path and search for
any pst.

strPath = "\\lmdatastore\data01\users\"
strUserName = "wperez"
strExtension = "pst"


Set objWMIService = GetObject("winmgmts:" _ <---- error in this block
& "{impersonationLevel=impersonate}!\\" _
& strPath & "\root\cimv2") ----> error in
this block

Set colItems = objWMIService. _
ExecQuery("Select * From Cim_DataFile " _
& "Where (Path = '" & strPath & "' & '" & strUserName & "' & And
Extension='" & strExtension & "'")

'
WScript.Echo "# of files found: " & colItems.Count
For Each objItem In colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "CIM_DataFile instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo "FileName: " & objItem.Name
WScript.Echo "FileSize (bytes): " & objItem.FileSize
WScript.Echo strpath & strUserName
Next

I am getting an error:
(18, 1) (null): 0x80041021

RE: Find PST file and give path and size by urkec

urkec
Thu May 08 11:13:00 CDT 2008

"freddy" wrote:

> I want to run the script from any computer and go to the path and search for
> any pst.
>
> strPath = "\\lmdatastore\data01\users\"
> strUserName = "wperez"
> strExtension = "pst"
>
>
> Set objWMIService = GetObject("winmgmts:" _ <---- error in this block
> & "{impersonationLevel=impersonate}!\\" _
> & strPath & "\root\cimv2") ----> error in
> this block
>
> Set colItems = objWMIService. _
> ExecQuery("Select * From Cim_DataFile " _
> & "Where (Path = '" & strPath & "' & '" & strUserName & "' & And
> Extension='" & strExtension & "'")
>
> '
> WScript.Echo "# of files found: " & colItems.Count
> For Each objItem In colItems
> Wscript.Echo "-----------------------------------"
> Wscript.Echo "CIM_DataFile instance"
> Wscript.Echo "-----------------------------------"
> Wscript.Echo "FileName: " & objItem.Name
> WScript.Echo "FileSize (bytes): " & objItem.FileSize
> WScript.Echo strpath & strUserName
> Next
>
> I am getting an error:
> (18, 1) (null): 0x80041021


I don't think you can use strPath both in the moniker and in the query.
Moniker should contain the server name and namespace you are connecting to.


--
urkec