troubleshooting Question

Switching Proxy On/Off Automatically script every time user switch between networks

Avatar of fadyaz
fadyazFlag for Qatar asked on
Wireless NetworkingWindows NetworkingMicrosoft Legacy OS
6 Comments2 Solutions409 ViewsLast Modified:
Hello,

I found a script to Enable/Disable proxy if the user inside the organization or outside the organization.

The VBS Script

'#==============================================================================
'#==============================================================================
'#  SCRIPT.........:  Enable Disable IE Proxy.vbs
'#  AUTHOR.........:  Stuart Barrett
'#  VERSION........:  1.0
'#  CREATED........:  15/09/10
'#  COPYRIGHT......:  2010
'#  LICENSE........:  Freeware
'#  REQUIREMENTS...:  
'#  DESCRIPTION....:  Enables or disables IE proxy on the local system
'#
'#  NOTES..........:  
'# 
'#  CUSTOMIZE......:  
'#==============================================================================
'#  REVISED BY.....:  
'#  EMAIL..........:  
'#  REVISION DATE..:  
'#  REVISION NOTES.:
'#
'#==============================================================================
'#==============================================================================

Const HKEY_CURRENT_USER = &H80000001
Set objShell = CreateObject("WScript.Shell")
strPC = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

On Error Resume Next

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
strValueName = "ProxyEnable"

objReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

'#==============================================================================
'#	If IE Proxy is currently enabled display message and ask user whether it
'#	should then be disabled
'#==============================================================================
If dwValue = 1 Then
	IEPrompt = MsgBox ("IE Proxy is currently ENABLED on " & strPC & _
	".  Do you want to DISABLE it?", vbQuestion+vbYesNo, "Disable IE Proxy")
	If IEPrompt = vbYes Then
		dwValue = 0
		objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue 
		MsgBox "IE Proxy is now DISABLED on " & strPC & _
		".",vbInformation, "Disable IE Proxy"
		ElseIf IEPrompt = vbNo Then
			MsgBox "IE Proxy is still ENABLED on " & strPC & _
			".",vbInformation, "Disable IE Proxy"
	End If
	'#==============================================================================
	'#	If IE Proxy is currently disabled display message and ask user whether it
	'#	should then be enabled
	'#==============================================================================
	ElseIf dwValue = 0 Then
		IEPrompt = MsgBox ("IE Proxy is currently DISABLED on " & strPC & _
		".  Do you want to ENABLE it?", vbQuestion+vbYesNo, "Enable IE Proxy")
		If IEPrompt = vbYes Then
			dwValue = 1
			objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
			MsgBox "IE Proxy is now ENABLED on " & strPC & _
			".",vbInformation, "Enable IE Proxy"
			ElseIf IEPrompt = vbNo Then
				MsgBox "IE Proxy is still DISABLED on " & strPC & _
				".",vbInformation, "Enable IE Proxy"
	End If
End If

But i need a solution apply the switching automatically instead of running the script every time user switch between networks.

In ex: if the user use the Organization network Enabling the proxy automatically and if he use another network the proxy must be disabled.


Regards,
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros