WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Status of Network Adapter


This example specifically looks for the 'Microsoft Loopback Adapter'. You can modify to fit your needs.
outputfile = "C:\temp\devoutput.txt" ;!!!!!!!!!!!!!! CHANGE TO FIT YOUR NEEDS
computername = "Peanut" ;!!!!!!!!!!!!!! CHANGE TO FIT YOUR NEEDS

Locator = ObjectCreate("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer(ComputerName)
Security = Service.Security_
Security.ImpersonationLevel = 3
;the WMI class Win32_NetworkAdapter, it returns all the adapters including the Virtual network adapters.
colAdapters = Service.ExecQuery("Select * from Win32_NetworkAdapter where name = 'Microsoft Loopback Adapter'")
found = 0
ForEach Adapter In colAdapters
   found = 1
   PNPDeviceID =  Adapter.PNPDeviceID
Next
colAdapters = 0
Security = 0
Service = 0
Locator = 0

If found
  Message('Microsoft Loopback Adapter','Found')
  ;Message('deviceid:',PNPDeviceID)
  params = StrCat('/c devcon -m\\',computername, ' status "',PNPDeviceID,'">"',outputfile,'"')
  ShellExecute('cmd.exe',params,'',@NORMAL,'' )
  result = FileGet(outputfile)
  Message(StrCat("Status of deviceid: ",PNPDeviceID),result)
  FileDelete(outputfile)
Else
  Message('Microsoft Loopback Adapter','NOT Found')
EndIf
Exit

Article ID:   W17317
File Created: 2007:07:03:14:29:28
Last Updated: 2007:07:03:14:29:28