BrokenThumb Posted September 25, 2012 Share Posted September 25, 2012 Hey All, Its me again, trying to hammer through some more scripts today. I was able to get this script up and running to change proxy settings automatically on IE9 and I wrote it in a way that my Users will be able to get visual feedback that their settings are changing. ; Script Start ;This portion launches the Internet Properties menu. Run ( "cmd" ) WinWaitActive ( "Administrator: C:\Windows\system32\cmd.exe" ) Send ( "rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4 {ENTER}" ) WinWaitActive ( "Internet Properties" ) WinClose ( "Administrator: C:\Windows\system32\cmd.exe" ) ;This section launches the LAN Settings. Send ( "!l" ) ;"Alt + l" ;The following unchecks the proxy server radio and sets it to Auto detect. WinWaitActive ( "Local Area Network (LAN) Settings" ) ControlCommand ( "Local Area Network (LAN) Settings", "", "Button6", "UnCheck", "" ) ControlCommand ( "Local Area Network (LAN) Settings", "", "Button2", "Check", "" ) ;This segment backs you out and closes the menu then displays a mesage letting you know the task is complete. Closes auto after 5 seconds. Sleep ( 1000 ) ;One Second break in script to show user the proxy settings have been changed. ControlClick ( "Local Area Network (LAN) Settings", "OK", 1 ) WinWaitActive ( "Internet Properties" ) ControlClick ( "Internet Properties", "OK", 1 ) MsgBox ( 0, "Proxy settings have been set to offsite.", "Your proxy settings have been changed. This window will close in five seconds.", 5 ) However as it is set up now, it shows the command prompt and I would like to remove that. So I looked up the RUN Function help page and I find that I need to add @SW_HIDE to make windows run in the background. However every time I make adjustments. (Code below) it hangs and keeps pausing itself. Looked around the forum and couldn't quite see my issue so I was hoping someone might be able to point out my fail for me. ; Script Start ;This portion launches the Internet Properties menu. Run ( "cmd", "", @SW_HIDE ) WinWaitActive ( "Administrator: C:\Windows\system32\cmd.exe" ) Send ( "rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,4 {ENTER}" ) WinWaitActive ( "Internet Properties" ) WinClose ( "Administrator: C:\Windows\system32\cmd.exe" ) ;This section launches the LAN Settings. Send ( "!l" ) ;"Alt + l" ;The following unchecks the proxy server radio and sets it to Auto detect. WinWaitActive ( "Local Area Network (LAN) Settings" ) ControlCommand ( "Local Area Network (LAN) Settings", "", "Button6", "UnCheck", "" ) ControlCommand ( "Local Area Network (LAN) Settings", "", "Button2", "Check", "" ) ;This segment backs you out and closes the menu then displays a mesage letting you know the task is complete. Closes auto after 5 seconds. Sleep ( 1000 ) ;One Second break in script to show user the proxy settings have been changed. ControlClick ( "Local Area Network (LAN) Settings", "OK", 1 ) WinWaitActive ( "Internet Properties" ) ControlClick ( "Internet Properties", "OK", 1 ) MsgBox ( 0, "Proxy settings have been set to offsite.", "Your proxy settings have been changed. This window will close in five seconds.", 5 ) Thanks Guys! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 25, 2012 Moderators Share Posted September 25, 2012 (edited) Hi, SilasMontgommeri. If you're hiding the window, how do you expect the WinWaitActive or Send commands to ever take effect? If you want to send to a hidden window you'll have to use ControlSend, although the help file does mention that it can be unreliable for command prompts. Or check opening the applet with ShellExecute instead and cut out the middle man ShellExecute("rundll32.exe", 'shell32.dll,Control_RunDLL inetcpl.cpl,,4') Edited September 25, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
BrokenThumb Posted September 25, 2012 Author Share Posted September 25, 2012 Ahhhh...I thought that when the window was hidden it would still take commands, just be hidden from the user's view. That makes since when you put it that way. I tried out your ShellExecute Function and it worked like a dream. I'll be sure to use that one instead. It's just a lot to try and take in all at once Thanks for the help JLogan! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 25, 2012 Moderators Share Posted September 25, 2012 Glad that worked for you. It is definitely a lot, but we all had a "Day 1" If you run into any bumps along the way, don't be afraid to ask questions. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
dmob Posted September 27, 2012 Share Posted September 27, 2012 ... and I wrote it in a way that my Users will be able to get visual feedback that their settings are changing.They could also interfere with the script by activating other windows before it is finished...I would use registry settings to change proxy settings. Halla if you need example... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now