Re: How can i speed up my script?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Ryan wrote:

I use one of the ping functions linked on this page to avoid the long
timeout if a remote computer is unavailable:

http://www.rlmueller.net/PingComputers.htm

Less common is to encounter a machine that does not have WMI installed. In
that case an error is raised on the "Set oReg" statement. I see you already
trap this error. I don't know of any way to reduce the timeout experienced
there.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

<ashline@xxxxxxxxx> wrote in message
news:1176383421.875059.106960@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I put together the following script to check, change and report
registry settings on remote machines. It is runnling very slow and I
think it "hangs" when a pc is off or unavailible. Does anyone have
any ideas on what I should change to speed things up?

Thanks for your time
Ryan

Const ForReading = 1
Const REGQ = "c:\plagent\REG QUERY"
Const HKEY_LOCAL_MACHINE = &H80000002

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
Set objTextFile = objFSO.OpenTextFile("c:\plagent\allws.txt",
ForReading)
Set fs = CreateObject("Scripting.FileSystemObject")
Set file = fs.OpenTextFile("C:\plagent\outallws.txt", 8, True)

strKeyPath = "SOFTWARE\Patchlink.com\Gravitix\Agent\Configuration"
strValueName = "ProxyName"
strValue = "gman.work.com"

On Error Resume Next
Do Until objTextFile.AtEndOfStream

strComputer = objTextFile.ReadLine
'WScript.Echo strComputer

Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
If Err.Number <> 0 Then
file.Write strComputer & " " & "Error: " & Err.Description &
VbCrLf
Err.Clear
Else

oReg.GetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,s1Value
oReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
oReg.GetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,s2Value
file.write strComputer & " " & s1Value & " " & s2Value & VbCrLf
End If
Loop

file.close

objTextFile.Close



.



Relevant Pages

  • Re: PowerStatus
    ... If it does reply to the ping, the wmi script might work. ... Obviously, if there is something wrong with wmi on the remote computer, it ... > IsComputerOn strComputer ...
    (microsoft.public.scripting.wsh)
  • Re: scp failing
    ... When you run scp from the command line, ... taking out the timeout block does *not* remove ... script and the suggested fixes, ... this script is running another script on a remote computer. ...
    (comp.lang.tcl)
  • PowerStatus
    ... I have the below script, but sometimes it can take up ... to 4-5 minutes to try and connect to the remote computer if it's not ... IsComputerOn strComputer ... Sub IsComputerOn ...
    (microsoft.public.scripting.wsh)
  • RE: Scanning tool for KB870669?
    ... It provides the option of connecting to a remote computer. ... strComputer = InputBox ... objReg.EnumKey HKLM, strKey, arrSubkeys ... For Each strSubkey In arrSubkeys ...
    (microsoft.public.security)
  • perl ssh with timeout?
    ... How can I use perl to connect to a remote computer via ssh with a timeout? ... The latter one I wasn't able to install anyway. ...
    (comp.lang.perl.misc)