This is something i wrote for my netbook, it uses the functionality in Windows 7 to bind tasks to events in the system log. You First need to copy this script and set a couple of values:
WScript.Sleep 20000
strComputer = "."
strProxyURL=""
strProxyPort=""
Set objShell = CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputerIP = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration")
For Each IPConfig in colComputerIP
If Not IsNull(IPConfig.IPAddress) Then
For intIPCount = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
strIPAddress = strIPAddress & "IP Address: " & IPConfig.IPAddress(intIPCount) & "~"
Next
End If
Next
If InStr(strIPAddress, "10.0.0.") > 0 Then
strTheIPAddress = Mid(strIPAddress, InStr(strIPAddress, "10.0.0."), InStr(InStr(strIPAddress, "10.0.0."), strIPAddress, "~") - InStr(strIPAddress, "10.0.0."))
Else
strTheIPAddress = "UNKNOWN"
End If
If Len(strTheIPAddress) > 1 And Right(strTheIPAddress, 1) = "~" Then
strTheIPAddress = Left(strTheIPAddress, Len(strTheIPAddress) - 1)
End If
If strTheIPAddress <> "UNKNOWN" Then
objShell.popup "UnSetting the Proxy",0,"Proxy Script",vbOK + vbInformation
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",0,"REG_DWORD"
Else
objShell.popup "Setting the Proxy to " & strProxyURL & ":" & strProxyPort,0,"Proxy Script",vbOK + vbInformation
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer",strProxyURL & ":" & strProxyPort,"REG_SZ"
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable",1,"REG_DWORD"
End If
Set strProxyURL and strProxyPort, to the proxy values you want to use. You will then notice I only have 1 “no proxy” network defined, “10.0.0.”, this is because thats the IP Range i use at home, and whilst in schools the IP range varies massively. Alter all the 10.0.0. to your IP range, you could also add another case (elseif) for 192.168.1. for example.
To set the proxy script to work on wireless connections you need to open up event viewer (right click computer -> Manage). Then in the tree menu open “Event Viewer -> Applications and Services -> Microsoft -> Windows ->WLAN Auto Config”
In there find an event with an id of 8000, e.g.
Then from the Side menu you need to click “Attach Task To This…” under Event 8000.
You can call the task what ever you like, probably a good idea to call it something like “Wireless Proxy Script”. Accept all the defaults for the task and then when asked for the program to run point it at the script you copied earlier in this post.
There should be a similar event in the Wired Auto Config logs that you can attach an identical event to.
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
[...] searching for a while i have come up with this: Proxy Setting Script for Windows 7 – Blog.Arcath.Net theres also instructions on how to bind it to the wireless connection [...]
November 24, 200910:51 am