Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Wed, 6 Aug 2008 16:43:15 -0700,    group: microsoft.public.win32.programmer.wmi        back       


How to reduce WMI connection timeout?   
I have a script that uses WMI to modify registry keys on hundreds of domain 
machines (running XP pro). In a nutshell, here's what the script does:

1. Pings each machine, one at a time.
2. If a machine does not reply to the ping, the script skips to the next 
machine.
2. If a machine does reply to the ping, the script uses WMI to connect to 
the machine and modify a registry key.

In a perfect world, the script would complete in a matter of seconds. 
However, sometimes the script cannot make a WMI connection to a machine even 
though the machine replied to the ping request. The line of code where it 
can hang is this:

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

When this happens, the script hangs for a minute or two before finally 
timing out and proceeding to the next machine. The end result is that the 
script can take 10-20 minutes to complete, depeding on how many machines 
can't make the WMI connection at that time. Incidentally, I've noticed when 
a machine fails to allow WMI connections, it also doesn't allow remote 
connections using Services, Regedit, or Computer Management. A manual reboot 
fixes the problem, but it happens sort of randomly across our domain in an 
unpredictable way.

So my question is this: How can I force the WMI connection attempt to 
timeout earlier - say after 5 seconds instead of 1-2 minutes? Or as an 
alternative, is there a way to modify registry keys remotely without using 
WMI?

Thanks for any help out there...
date: Wed, 6 Aug 2008 16:43:15 -0700   author:   D.P. Roberts

Re: How to reduce WMI connection timeout?   
D.P. Roberts wrote:

>I have a script that uses WMI to modify registry keys on hundreds of domain 
>machines (running XP pro). In a nutshell, here's what the script does:
>
> 1. Pings each machine, one at a time.
> 2. If a machine does not reply to the ping, the script skips to the next 
> machine.
> 2. If a machine does reply to the ping, the script uses WMI to connect to 
> the machine and modify a registry key.
>
> In a perfect world, the script would complete in a matter of seconds. 
> However, sometimes the script cannot make a WMI connection to a machine 
> even though the machine replied to the ping request. The line of code 
> where it can hang is this:
>
> Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
>      & strComputer & "/root/default:StdRegProv")
>
> When this happens, the script hangs for a minute or two before finally 
> timing out and proceeding to the next machine. The end result is that the 
> script can take 10-20 minutes to complete, depeding on how many machines 
> can't make the WMI connection at that time. Incidentally, I've noticed 
> when a machine fails to allow WMI connections, it also doesn't allow 
> remote connections using Services, Regedit, or Computer Management. A 
> manual reboot fixes the problem, but it happens sort of randomly across 
> our domain in an unpredictable way.
>
> So my question is this: How can I force the WMI connection attempt to 
> timeout earlier - say after 5 seconds instead of 1-2 minutes? Or as an 
> alternative, is there a way to modify registry keys remotely without using 
> WMI?
>
> Thanks for any help out there...

Similar questions have been asked several times, and I'm fairly sure there 
is no way to reduce the WMI connection timeout. Many people use a ping 
function and specify a short timeout. Al Dunbar has suggested using Net View 
to get a list of available computers. However, it appears this won't help 
you.

In my experience the WMI connection fails (even if the computer responds to 
a ping) if the remote client does not have WMI installed (a Win9x client for 
example), or the OS version does not support the WMI class. In rare 
instances WMI is either not running or is corrupted. If nothing seems to 
connect to the remote computer something else is wrong, especially if a 
reboot of the remote computer fixes it. Can you verify that the WMI service 
is running before the reboot?

I don't think it will help in your case (because a reboot fixes the 
problem), but documentation suggests it can help (with newer OS's) to 
specify authenticationLevel:

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
    & strComputer & "/root/default:StdRegProv")

-- 
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
date: Wed, 6 Aug 2008 19:30:28 -0500   author:   Richard Mueller [MVP]

Re: How to reduce WMI connection timeout?   
On Aug 6, 4:43 pm, "D.P. Roberts"  wrote:
>
> So my question is this: How can I force the WMI connection attempt to
> timeout earlier - say after 5 seconds instead of 1-2 minutes? Or as an
> alternative, is there a way to modify registry keys remotely without using
> WMI?
>
> Thanks for any help out there...



Hi,

You can use the following APIs to establish a connection to
a predefined registry handle on another computer and backup
the Windows registry:

	GetCurrentProcess()

	OpenProcessToken()	TOKEN_ADJUST_PRIVILEGES

	LookupPrivilegeValue()	SE_BACKUP_NAME

	AdjustTokenPrivileges()	SE_PRIVILEGE_ENABLED

	RegConnectRegistry()

	RegEnumKeyEx()

	RegCreateKeyEx()

	RegSaveKeyEx()

	RegCloseKey()

	AdjustTokenPrivileges(hToken, TRUE, NULL, 0, NULL, NULL);

	CloseHandle()

http://msdn2.microsoft.com/en-us/library/ms683179.aspx

http://msdn2.microsoft.com/en-us/library/aa379295.aspx

http://msdn2.microsoft.com/en-us/library/aa379180.aspx

http://msdn2.microsoft.com/en-us/library/aa375202.aspx

http://msdn2.microsoft.com/en-us/library/ms724840.aspx

http://msdn2.microsoft.com/en-us/library/ms724862.aspx

http://msdn2.microsoft.com/en-us/library/ms724844.aspx

http://msdn2.microsoft.com/en-us/library/ms724919.aspx

http://msdn2.microsoft.com/en-us/library/ms724837.aspx

http://msdn2.microsoft.com/en-us/library/ms724211.aspx

Kellie.
date: Thu, 7 Aug 2008 07:56:43 -0700 (PDT)   author:   Kellie Fitton

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us