Check for enabled NIC and execute command  
Author Message
tbonanni





PostPosted: Top

VB Scripts >> Check for enabled NIC and execute command Hello all. I am trying to write a script with minimal vbs knowledge. I have
downloaded scriptomatic 2.0 and have made some progress but have come to a
head.

Background:
We use WSUS for all local and remote users in an NT4 domain (soon to be
migrated to AD). Remote users connect via Cisco VPN client. The clients
installs as a network device, is disable when not in use and enables when
the GUI is loaded. The detection frequency setting for WSUS runs at
intervals of 8 - 20 hours according to the documentation. This causes the
remote client to almost never check for updates.

Solution:
Write a script which checks or better still listens if the VPN is active
(objItem.ServiceName(CVirtA) and when it becomes active
(objItem.NetConnectionStatus=2) then run the command (wuauclt /detectnow).

I have the beginnings of something pasted in below which obviously doesnt
quite work unless you comment a few lines here and there, but doing that
does not give the desired result.

Can I use wsh/vbs to monitor the connection or would this need to work on a
timer?
If a timer how would that affect memory consumption on the notebook?

TIA.

' start script

On Error Resume

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

arrComputers = Array("localhost")
For Each strComputer in arrComputers
WScript.Echo
WScript.Echo "======================"
WScript.Echo "Computer: "& strComputer
WScript.Echo "======================"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_NetworkAdapter", "WQL", _
wbemFlagReturnImmediately
+ wbemFlagForwardOnly)

If objItem.ServiceName="CVirtA" And objItem.NetConnectionStatus="2" Then
' C:\Windows\SYSTEM32\wuauclt.exe /detectnow
End If

Visual Studio153