| |
avipenina
Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
|
Hi, i've this script On Error Resume Next Set objNetwork = CreateObject("Wscript.Network") strLocalComputer = objNetwork.ComputerName strComputer = Wscript.Arguments.Item(0) If strComputer = "" then Wscript.echo "You didn't specified any machine to connect to..." Wscript.quit End If Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colLoggedEvents = objWMIService.ExecQuery _ ("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'application' AND " _ & "EventCode = '0'") For each objEvent in colLoggedEvents Wscript.echo "Computer: " & objEvent.ComputerName & _ vbnewline & _ "Time : " & objEvent.TimeWritten & _ vbnewline & _ "Event ID: " & objEvent.EventCode & _ vbnewline & _ vbnewline & _ "Description: " & objEvent.Message & _ vbnewline & _ "Source: " & objEvent.SourceName & _ vbnewline & _ "Type: " & objEvent.Type & _ vbnewline & _ "User: " & objEvent.User & _ vbnewline next wscript.echo "Can't connect to the specified machine" this script needs Argument like machine name to show this info only local machine name work it's ok. my problem is that i use this line "On Error Resume Next" now under the next i've this line "wscript.echo "Can't connect to the specified machine"" i put this line if the user put wrong machine name or there is an error that will go to this line, the problem is even if the script work it show this line "Can't connect to the specified machine" in the end of the script WHY? and how i resolved that will show the error only if the machine name is incorrect? Thanks
|
|