Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Trouble with winmgmts in vbs...

Reply
 
Old 11-07-2008   #1 (permalink)
skipjack


 
 

Trouble with winmgmts in vbs...

I've got a script that goes out and reads registry keys on computers
on our network and then writes them to a .csv.

It works... but only for one computer at a time. If I try to run a
list of computer names through it.. it just keeps pulling the registry
from the first machine.

Here's the winmgmts line:

==============================
Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\
\" & strComputer & "/root/default:StdRegProv")
=========================

The strComputer variable changes just fine as the script moves through
the list. But, for some reason the winmgmts command doesn't want to
look at anything other than the first computer... even when instructed
not to.

Does the winmgmts need to be reset or something? I just don't get
it.


My System SpecsSystem Spec
Old 11-07-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Trouble with winmgmts in vbs...


"skipjack" <skipjack2001@xxxxxx> wrote in message
news:3c57e507-2478-4c20-ad18-5980a72a5b2e@xxxxxx
Quote:

> I've got a script that goes out and reads registry keys on computers
> on our network and then writes them to a .csv.
>
> It works... but only for one computer at a time. If I try to run a
> list of computer names through it.. it just keeps pulling the registry
> from the first machine.
>
> Here's the winmgmts line:
>
> ==============================
> Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\
> \" & strComputer & "/root/default:StdRegProv")
> =========================
>
> The strComputer variable changes just fine as the script moves through
> the list. But, for some reason the winmgmts command doesn't want to
> look at anything other than the first computer... even when instructed
> not to.
>
> Does the winmgmts need to be reset or something? I just don't get
> it.
>
No, winmgmts doesn't need to be reset, although the values retrieved might
if you encounter a computer that cannot be connected to (because of
permissions, old OS, corrupt WMI, disabled DCOM, remote computer offline,
etc.). We need to see more code to troubleshoot further. Hopefully you don't
use "On Error Resume Next" throughout as that makes troubleshooting very
difficult and could account for what you observe. You might be able to
troubleshoot the problem yourself by removing "On Error Resume Next".

When I code similar things I use "On Error Resume Next" only for the
GetObject("winmgmts:...") statement. Then I trap the error if the computer
cannot be contacted with "If (Err.Number <> 0) Then" and then restore normal
error handling with "On Error GoTo 0". If this doesn't help, we need to see
more code.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
access denied on a remote computer with winmgmts VB Script
winmgmts not working on some servers VB Script
How to terminate a Win32 process without using "winmgmts:" VB Script
LAN trouble can- see only one way Vista General
LAN trouble Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46