inetwiz is a tool which I have been using in Windows XP to update the IE proxy setting.
The manual process has been a pain and I wanted to automate it badly.
Experimented with multiple tools - Registry updates, Python. A friend suggested to use VBS.
The VBS did the trick and I was able to use Wscript Run, AppActivate and sendKeys method to automate the proxy update and opening the URL in internet explorer.
Here is the script
option explicit
' Global variable used by mySendKeys function.
dim Wsh
set Wsh = Wscript.CreateObject("Wscript.
Shell")
if (Wscript.Arguments.Count < 2) Then
Wscript.Echo "Usage: i /auto|/man URL"
Wscript.Quit(1)
End if
'WScript.Echo (Wsh.RegRead("HKCU\Software\
Microsoft\Windows\ CurrentVersion\Internet Settings\ProxyEnable"))
if (Wscript.Arguments(0) = "/man") Then
' VB Script does not support double equal.
' If Proxy is not enabled, enable it.
if (Wsh.RegRead("HKCU\Software\
Microsoft\Windows\ CurrentVersion\Internet Settings\ProxyEnable") = 0) Then
enableManProxy() End if
Wsh.Run "iexplore " & Wscript.Arguments(1)
Elseif (Wscript.Arguments(0) = "/auto") Then
' If Auto Proxy is not enabled.
' VB Script does not support double equal.
if (Wsh.RegRead("HKCU\Software\
Microsoft\Windows\ CurrentVersion\Internet Settings\ProxyEnable") = 1) Then
enableAutoProxy() End if
Wsh.Run "iexplore " & Wscript.Arguments(1)
Else
Wscript.Echo "Usage: i /auto|/man URL"
End if
Function enableAutoProxy()
' Enable Automatic Proxy
Wsh.Run "inetwiz"
Wscript.Sleep 1000 ' Give time for application window to open.
mySendKeys "%n" ' Alt + n
mySendKeys " " ' Space
mySendKeys "{Tab}" ' Tab
mySendKeys " " ' Space
mySendKeys "{Tab}" ' Tab
mySendKeys "{Tab}" ' Tab
mySendKeys " " ' Space
mySendKeys "%n" ' Alt + n
mySendKeys "%o" ' Alt + 0
mySendKeys "%n" ' Alt + n
mySendKeys " " ' Space/Finish button
End Function
Function enableManProxy()
Wsh.Run "inetwiz"
Wscript.Sleep 1000 ' Give time for application window to open.
mySendKeys "%n" ' Alt + n
mySendKeys " " ' Space
mySendKeys "{Tab}" ' Tab
mySendKeys " " ' Space
mySendKeys "{Tab}" ' Tab
mySendKeys " " ' Space
mySendKeys "%n" ' Alt + n
mySendKeys "%n" ' Alt + n
mySendKeys "%n" ' Alt + n
mySendKeys "%o" ' Alt + 0
mySendKeys "%n" ' Alt + n
mySendKeys " " ' Space/Finish button
End Function
Function mySendKeys(key)
wsh.AppActivate "Internet Connection Wizard"
wsh.SendKeys key
End Function
No comments:
Post a Comment