Jump to content

Recommended Posts

Posted

Hi,

 

I have a teacher who uses a laptop in work but also takes it home.

 

I need a script that she can run every time she enters the school or when at home.

 

So here's what I need:

 

When at home:

- Check "Automatically detect proxy settings"

- Uncheck "Use a proxy server..."

 

When at school:

- Uncheck "Automatically Detect Proxy Settings"

- Check "Use a proxy server..."

 

As long as the laptop remembers the proxy's IP address and port number, it should work.

Posted

if you look at the reg values for

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]

 

these hold the internet settings for the browser export out the reg values for when you have set "School internet" and then blank then for home internet gives you two reg keys which can be run directly or called via a script

Posted

Hi,

I needed to do a temporary fix for someone a while ago - I used AutoIT to do it as it was quick and easy to produce a GUI on a machine that didn't have Visual Studio installed - there are obviously much better ways to do this but there you are.

The original script did more than just the proxy settings, so I have amended it and only left the proxy bits in there.

JustProxy.zip

I can't guarantee that it will work in your environment (works on my Windows 7 machine), but it may get you a quick fix whilst you get something more permanent together.

Feel free to re-compile it if you don't trust my EXE!

Oh, and I know the code is messy!! - It was a quick fix after all!!

Ash.

Posted
Set WshShell = WScript.CreateObject("WScript.Shell")

 

DimSetting = WshShell.RegRead ("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable")

 

 

If DimSetting = 1 Then

'Wscript.Echo "Proxy is Currently Enabled"

 

 

returnvalue=MsgBox ("Do you want to DISABLE the Proxy, to connect to the internet outside of school?", 36, "Proxy state is Currently ENABLED")

 

 

 

 

if returnvalue = 6 then

' BEGIN CALLOUT A

WshShell.RegWrite "HKCU\Software\Microsoft\Windows" & _

"CurrentVersion\Internet Settings\ProxyEnable", _

0, "REG_DWORD"

' END CALLOUT A

 

 

wShshell.Run "taskkill /im iexplore.exe",0,True

WScript.Sleep 500 'give kill time to take effect

 

 

'Inform User that the task is done.

Mybox = MsgBox("Proxy is now disabled. You can now connect to the internet outside of school" ,vbOkOnly,"Proxy is Disabled")

're-launch internet explorer

wShshell.Run "iexplore.exe"

End If

WScript.Quit

 

 

 

 

Else

'Wscript.Echo "Proxy is Currently Disabled"

End If

 

 

 

 

'On Error Resume Next

 

 

returnvalue=MsgBox ("Do you want to ENABLE the Proxy, to connect to the internet at school?", 36, "Proxy state is Currently DISABLED")

 

 

If returnvalue = "" Then

WScript.Quit

End If

 

 

if returnvalue = 6 then

' BEGIN CALLOUT A

WshShell.RegWrite "HKCU\Software\Microsoft\Windows" & _

"CurrentVersion\Internet Settings\ProxyEnable", _

1, "REG_DWORD"

WshShell.RegWrite "HKCU\Software\Microsoft\Windows" & _

"CurrentVersion\Internet Settings\ProxyServer","yourschoolproxyaddresshere:80", "REG_SZ"

WshShell.RegWrite "HKCU\Software\Microsoft\Windows" & _

"CurrentVersion\Internet Settings\ProxyOverride","", "REG_SZ"

' END CALLOUT A

 

 

 

 

wShshell.Run "taskkill /im iexplore.exe",0,True

 

 

WScript.Sleep 500 'give kill time to take effect

 

 

'Inform User that the task is done.

Mybox = MsgBox("Proxy is now enabled, for use within school",vbOkOnly,"Proxy Enabled")

're-launch internet explorer

wShshell.Run "iexplore.exe"

End If

 

 

WScript.Quit

 

This is the quick and dirty bodge that I have previously used, patched together from various sources on t'interwebs- I take no credit for it! It will prompt user to disable/enable proxy and will launch iexplore once complete.

 

Save as whateveryouwant.vbs

 

You may want to investigate implementing a PAC file or looking at using a transparent proxy in the future though

Posted
a Proxy PAC file is probably the way to go. However a slightly quicker albeit not as clean approach would be to have GPO always set the "Use Proxy Server" option then you'd only need 1 batch file for the user to run which unselects the options whenever they are away from the office. When they come back to the office, GPO will re-apply and the proxy settings will be in use again.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...