Prev: OCR in browser using MODI in VBscript - Any thoughts appreciated
Next: InputBox: how do I hide user input
From: ccc2501 on 16 Feb 2010 11:07 Ok, here's my need. I am writing a script that does a few things, but I'm having trouble just pulling the "production" IP address into a variable, to then use in the rest of the script. I've see plenty of scripts to ping remote hosts, but that's not what I need. I've also worked up a few scripts on my own, but they all pull every IP on the machine, or require you to know the intenal ID of the NIC interface you need queried. The issue with this is that the ID is assigned randomly, and it's something you just have to know. I'm rather new at VBScript, and I've tried to muddle through it on my own before asking, but now I need help. Any advice would be greatly appreciated. -- ccc2501
From: ylafont on 16 Feb 2010 13:55
Here is a function test to see if the address is alive, hope it helps Function Reachable(strComputer) ' On Error Resume Next Dim wmiQuery, objWMIService, objPing, objStatus wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer & "'" Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set objPing = objWMIService.ExecQuery(wmiQuery) For Each objStatus in objPing If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then Reachable = False 'if computer is unreacable, return False Else Reachable = True 'if computer is reachable, return true End If Next End Function "ccc2501" wrote: > > Ok, here's my need. I am writing a script that does a few things, but > I'm having trouble just pulling the "production" IP address into a > variable, to then use in the rest of the script. I've see plenty of > scripts to ping remote hosts, but that's not what I need. I've also > worked up a few scripts on my own, but they all pull every IP on the > machine, or require you to know the intenal ID of the NIC interface you > need queried. The issue with this is that the ID is assigned randomly, > and it's something you just have to know. > > I'm rather new at VBScript, and I've tried to muddle through it on my > own before asking, but now I need help. Any advice would be greatly > appreciated. > > > -- > ccc2501 > . > |