Disable Network interface with a vbscript and devcon.

G

Guest

Hi, I want to run a script with MOM that will run on a windows 2003 server.
It's a vbscript that run devcon.exe to disable a network card if the card is
active. When I run the script manually, it works perfectly, but when I run
it with my MOM's client. It says "Disabled Failed" in my log file and the
connection still active. I put my MOM's service account administrator of the
compute, the account is also Domain admin.

Here is the script :
-----------------------------------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")

For Each objItem in colItems
If objItem.NetConnectionID= "Test Louis" Then '("Test Louis is the name
of my connection)
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = WINDOW_TYPE
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")

'Parse the Id of the card to trunk at the good caracter
IdCarteReseau = objItem.PNPDeviceID
IdCarteReseau = mid(IdCarteReseau,5, 99)
pos = InStr(IdCarteReseau,"\")
IdCarteReseau = Left(IdCarteReseau, (pos -1))
IdCarteReseau = "PCI\" & IdCarteReseau

errReturn = objProcess.Create("C:\Windows\system32\cmd.exe /C
C:\Devcon\Devcon.exe disable " & chr(34) & IdCarteReseau & chr(34) & " >>
C:\Temp\verificationCarteReseau.txt", null, objConfig, intProcessID)

End If
Next
 
G

Guest

I solve my problem, instead of using devcon, I disable the card with the
netsh command line tool provide by Microsoft. I'm not sure if it work win
Win 2000 srv. My problem was on a Win 2003 srv.

Louis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top