Login | |
|
 |
RE: newb syntax problem - 6/24/2008 5:05:53 AM
|
|
 |
|
| |
ebgreen
Posts: 5041
Score: 31
Joined: 7/12/2005
Status: offline
|
Here is your code properly indented. My comments are in red Option Explicit Set WshShell = CreateObject("WScript.Shell") Set colComputers = GetObject("LDAP://OU=Civic, DC=Honda, DC=win") For Each objComputer in colComputers strComputer = objComputer.CN Wscript.Echo strComputer Wscript.Echo "------------" If CheckConnection(strComputer) = True Then This If has no matching End If 'WScript.Echo "connected " & strComputer 'On Error Resume Next Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") If Err.Number <> 0 Then Wscript.Echo "WMI not working on: " & strComputer End If On Error Goto 0 On Error Resume Next Set colAccounts = objWMIService.ExecQuery _ ("Select * From Win32_UserAccount Where LocalAccount = TRUE") If Err.Number <> 0 Then Wscript.Echo "Null value from user_acct: " & strComputer End If On Error Goto 0 On Error Resume Next For Each objAccount in colAccounts If Left (objAccount.SID, 6) = "S-1-5-" and Right(objAccount.SID, 4) = "-500" Then Wscript.Echo objAccount.Name If Err.Number <> 0 Then Wscript.Echo "Null value from objacct: " & strComputer End If Exit For On Error Goto 0 Else Wscript.Echo "no conn to " & strComputer End If Wscript.Echo "____________" Next 'This function pings strComputer and returns a false if the ping was unsuccessful Function CheckConnection(strComputer) PINGFlag = Not CBool(WshShell.run("ping -n 1 " & strComputer, 0, True)) CheckConnection = PINGFlag End Function
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|