netsh is an .exe file. You cannot invoke it directly from a VB Script. Use
the "run" or "exec" method to invoke it. If you're not familiar with these
methods, use calc.exe as a practice program before moving on to netsh. You
should also download the helpfile script56.chm from the Microsoft site.
Alternatively (and I suggest this even though you're in a scripting and not
a batch file newsgroup), you could stick to a batch file like so:
1. Use cscript.exe to invoke the script I gave you.
2. Terminate it with wscript.quite(x) where you set x=0 if the adapter is
disconnected, x=1 if it is connected.
3. Use your batch file to check the %ErrorLevel% of cscript.exe. "0" means
the adapter is disconnected.
4. Invoke netsh according to this error level.
"Joey" <> wrote in message
news:...
> Hi
>
> I am trying to disable the NetConnectionID when the output shows as
> DISABLED. I cant see mt oget it to work with this
>
> iEthernet = 0: iWireless = 9
> aStatus = Split("Disconnected/Connecting/Connected/Disconnecting/" _
> & "Hardware not present/Hardware disabled/Hardware malfunction/" _
> & "Media disconnected/Authenticating/Authentication succeeded/" _
> & "Authentication failed", "/")
> Set oWMIService = GetObject("winmgmts:\\.\root\CIMV2")
> Set colItems = oWMIService.ExecQuery( _
> "SELECT * FROM Win32_NetworkAdapter",,48)
> For Each oItem In colItems
> If (oItem.AdapterTypeId = iEthernet _
> Or oItem.AdapterTypeId = iWireless) _
> And Not IsNull(oItem.NetConnectionStatus) _
> Then WScript.Echo oItem.NetConnectionID & ": " _
> & aStatus(oItem.NetConnectionStatus)
> If (astatus(oItem.NetConnectionStatus) = "Media disconnected")
> netsh interface set interface oItem.NetConnectionID DISABLED
> Next
>
> Can you point me in the right direction?
>
> Thanks
>
>
> "Pegasus [MVP]" <> wrote in message
> news:...
>>I suppose you use the method you had in mind when you wrote "I know how to
>>disable it with netsh ".
>>
>> "Joey" <> wrote in message
>> news:...
>>> how do I disable the nics showing as "Media disconnected"?
>>
>>
>
>
|