WPKG over VPN
I have configured all computers to have GPO startup script to run this script instead of wpkg-start.bat only if a computer is present on local subnet (C class) and doesn't have an IP belonging to VPN IP pool. I'm running a small OpenVPN client set. All updates to this script or the whole concept are welcome!
Changes
- VPN VBs script now called within batch file (keeps main WPKG shell window hidden)
More Changes
If you have the wpkg clients installed and if you use the wpkg service, set up a logon delay (3 minutes for example). You can run the check-vpn.vbs script in the domain logon script to determine whether the client is in the local subnet(s) or not. If the Client is in the VPN subnet (errorlevel 1), just stop the WPKG Service. (net stop "WPKG Service". Another possible solution is to add this "workaround batch script" to the regular tasks and run it for example every 10 Minutes.
check-vpn.vbs
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48)
Subnet="192.168.10."
IPStart=245
IPEnd=254
For Each adapter in colItems
If Not IsNull(adapter.IPAddress) Then
For i = 0 To UBound(adapter.IPAddress)
IP = CStr(adapter.IPAddress(i))
Host = CStr(Trim(Replace(IP, Subnet, "")))
Dots = InStr(Host, ".")
if Dots = 0 then
Host = CInt(Host)
if Host >= IPStart and Host <= IPEnd then
'NO-WPKG: VPN connection present
Wscript.Quit 1
else
'START-WPKG: local network present
Wscript.Quit 0
end if
end if
Next
end if
Next
'NO-WPKG: local network not present
Wscript.Quit 1
wpkg-start-vpn.bat
@echo off
cls
set WPKGROOT=\\server\wpkg$
set SOFTWARE=%WPKGROOT%\content
call cscript %WPKGROOT%\check-vpn.vbs > nul
if ERRORLEVEL 1 goto END
%WPKGROOT%\wpkg.js /synchronize /quiet /nonotify
:END