Difference between revisions of "WPKG over VPN"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
(New page: I have configured all computers to have GPO startup script to run this script. This scripts calls '''wpkg-start.bat''' only if a computer is present on local subnet (C class) and doesn't h...)
 
m
Line 44: Line 44:
 
set shell=nothing
 
set shell=nothing
 
</source>
 
</source>
 +
 +
[[Category: Documentation]]

Revision as of 17:35, 3 January 2009

I have configured all computers to have GPO startup script to run this script. This scripts calls 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!

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=252

LocalNetwork=0

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
					'VPN connection 
					Wscript.Quit
				else
					LocalNetwork=1
				end if
			end if
		Next
	end if 
Next 

'stop if we're not on local subnet
if LocalNetwork=0 then
	Wscript.Quit
end if 

dim shell
set shell=createobject("wscript.shell")
shell.run "\\vboxsrv\wpkg\wpkg-start.bat"
set shell=nothing