Proxy settings

Dell / Precision 530
July 15, 2009 at 15:10:18
Specs: Windows, Dell percision 530
I am to check our proxy settings throughout the night as one of our monitoring checks. There are about 5 to set. I want to create a batch file that calls a registry file to set the proxy info and then I would like a new session of IE to open to test these changes. Now instead of getting to fancy a popup dialog can ask me whether or not the proxy server is showing good, (A yes or no dialog) off of that dialog answer would determine the next decision. My question is, is this possible? I would assume yes but here is how I would like my logic to go (I think)
1. a .reg file to change proxy settings
2. Call Internet explorer.exe
3.Pop up dialog to ask yes or no (If it worked)
4. If yes
5. Then Close IE window
6. Call next .reg file to change to next proxy server
7. Open IE window
8. Pop up dialog to ask if yes or no
9
10
11
.
.
.
.
I think you get the idea

Sound like this idea may work?

It is better than click 1,000 times ctrl copy ctrl paste nex proxy info ... e.t.c.

Learning in progress..........


See More: Proxy settings

Report •


#1
August 17, 2009 at 18:42:39
This is the same VB Script that I posted on your other question, but it has an added Yes/No message box that decides if it should continue to run the for_next_loop or not.
I chose to embed an If-then-else loop to do it instead of a Do_while_loop simply becuase it just seemed easier for people to understand with the if-then-else loop. Also I would be a bigger fan of using F5 to refresh the page then using ALt-F4 to close the window.

Option Explicit

Dim WshShell, objRegistry, question
Dim strComputer, strProxyPath, arrProxyServers, Server

Set WshShell = CreateObject("WScript.Shell")
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strProxyPath = "Software\Microsoft\Windows\CurrentVersion\"&_
"Internet Settings"

'Array of your Proxy servers
arrProxyServers = array("http://ProxyServerName1:80","http://ProxyServerName2:80",_
"http://ProxyServerName3:80","http://ProxyServerName4:80",_
"http://ProxyServerName5:80","http://ProxyServerName6:80")

question=vbYes

'For_Each_Next loop, runs through each Proxy server,
'Opening IE, waiting for a bit, then closing IE
For each Server in arrProxyServers
If question=vbYes then
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strProxyPath, "ProxyEnable", 1
objRegistry.SetStringValue HKEY_CURRENT_USER, strProxyPath, "ProxyServer", server
WshShell.run "iexplore"
Wscript.sleep 5000
question=MsgBox( "Did the Proxy work?", 4, "Proxy Check")
WshShell.SendKeys "%{F4}" 'or you could simply use {F5} to refresh.
else
wscript.quit
end if
next


Report •

#2
August 17, 2009 at 19:13:32
Got to thinking, it should have been an if-elseif loop.

Option Explicit

Dim WshShell, objRegistry, question
Dim strComputer, strProxyPath, arrProxyServers, Server

Set WshShell = CreateObject("WScript.Shell")
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strProxyPath = "Software\Microsoft\Windows\CurrentVersion\"&_
"Internet Settings"

'Array of your Proxy servers
arrProxyServers = array("http://ProxyServerName1:80","http://ProxyServerName2:80",_
"http://ProxyServerName3:80","http://ProxyServerName4:80",_
"http://ProxyServerName5:80","http://ProxyServerName6:80")

question=vbYes

For each Server in arrProxyServers
If question=vbYes then
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strProxyPath, "ProxyEnable", 1
objRegistry.SetStringValue HKEY_CURRENT_USER, strProxyPath, "ProxyServer", server
WshShell.run "iexplore"
Wscript.sleep 5000
question=MsgBox( "Did the Proxy work?", 4, "Proxy Check")
WshShell.SendKeys "%{F4}" 'or you could simply use {F5} to refresh.
elseif question=vbNo then
Wscript.echo "Failure of server " & server
wscript.quit
end if
next


Report •

#3
August 17, 2009 at 21:35:48
You guys are awesome thanks for all the help

Learning in progress..........


Report •

Related Solutions


Ask Question