CheckPoint VPN Client Stop/Start vbs Script

'Connect to a local computer's object and declare services class for WMI

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery _
("Select * from Win32_Service")

' Set a VPN service for the next operations

Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='SR_WatchDog'")

'Check status of the service. If the service is up, stop it and vice versa

For Each objService in colServiceList
Status = objService.State
If Status="Running" Then
objService.StopService()
x=1
Else
objService.StartService()
x=0
End if
Next

If x=1 Then
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='SR_Service'")
For Each objService in colServiceList
objService.StopService()
Next
end if

2 comments:

Anonymous said...

Hi - this seems to nail toggling well for Checkpoint VPN client. Could you also post discriptive breakdown for those of us still on a WMI / VBS object oriented coding learning curve.

OLS

ale1v said...

I've added comments, hope it'd be helpful :)

Recent Posts