ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Windows Query working on some computer, and not working on others?!? (https://www.excelbanter.com/excel-programming/443507-windows-query-working-some-computer-not-working-others.html)

Charlotte E[_2_]

Windows Query working on some computer, and not working on others?!?
 
Hi all,

I have this small script to get the domain of the PC:
__________________________________________________ ____________________
Dim WMIService As Object
Set WMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\.\root\cim v2")

Dim WindowsQuery As Object
Set WindowsQuery = WMIService.ExecQuery("Select * from
Win32_ComputerSystem")

Dim PC As Object
Dim PD As String

For Each PC In WindowsQuery
PD = PC.Domain
Next
__________________________________________________ ____________________

But, on computers it work, and on other computers, the script return runtime
error 430 in the "For Each PC" line?!?

All computers are running "WinXP Pro 32-bit"???

And it doesn't matter, if I'm requesting Domain or other PC information - it
still work on some computers, and not on others?!?

What am I missing???


TIA...



Paul Robinson

Windows Query working on some computer, and not working on others?!?
 
Hi
It might help to specify the correct object type of WMIService,
WindowsQuery and PC (reference the libraries required using Tools,
References). Also, are you sure that Windowsquery is not Nothing on
some PC's?
Just things to try.
regards
Paul

On Aug 14, 10:18*am, "Charlotte E" wrote:
Hi all,

I have this small script to get the domain of the PC:
__________________________________________________ ____________________
Dim WMIService As Object
Set WMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\.\root\cim v2")

Dim WindowsQuery As Object
Set WindowsQuery = WMIService.ExecQuery("Select * from
Win32_ComputerSystem")

Dim PC As Object
Dim PD As String

For Each PC In WindowsQuery
* * PD = PC.Domain
Next
__________________________________________________ ____________________

But, on computers it work, and on other computers, the script return runtime
error 430 in the "For Each PC" line?!?

All computers are running "WinXP Pro 32-bit"???

And it doesn't matter, if I'm requesting Domain or other PC information - it
still work on some computers, and not on others?!?

What am I missing???

TIA...




All times are GMT +1. The time now is 02:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com