Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Changing windows settings

I'm looking to write a small program for a friend who has to use a proxy to access the internet at work, but when they bring thier laptop home, no proxy is required, and before they can access the internet, the following procedure is required:
Control pannel -> internet Properties -> Connections Tab -> LAN Settings Button -> Invert Proxy Server check box

This isn't too bad, but it is a bore to do twice a day.
I'm looking for a way to access and change this setting by having an executible my friend can run from the desktop.
(double click and its changed, no windows or extra work)
I've never played with windows settings before, so I'm clueless on this one.

Any help or references would be appreciated

Craig Sisk
Monday, October 14, 2002


A lot of Windows settings are stored in the Registry.  While you shouldn't normally muck around in the Registry, it's sometimes can be a fun thing to do.

I'd suggest you write two script files for your friend.

The first would be called "Work.vbs" (it can be created in notepad or your favorite text editor) and would contain the following script:

Option Explicit

Dim shell
Set shell = CreateObject("WScript.Shell")

shell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"

The second file would be "Home.vbs" and would contain the exact same code as above, but would have a 0 for the parameter value instead of 1.

Double clicking and running the script "Work.vbs", sets the ProxyEnable registry value and enables proxy use.  "Home.vbs" does just the opposite.

Guy Incognito, MCSD DOA PITA
Monday, October 14, 2002

this is win32/windows internet stuff, not really .net...

i believe this one is set by internetsetoption.

you can also write a proxyautoconfig file which could somehow detect where you are and point to the right place, but that's more work and gets run every time you hit a page. but hey, i use it as a cheesy anti-evil-advertising filter.

you could write a .net thingy (assembly? I still don't know all the terminology) to change all these settings, if nothing exists yet.

late at night
Tuesday, October 15, 2002

oh yeah, look into making it a com class and you could even put it on the tools menu. Look up Internet Explorer Extensions.
Been meaning to do that with some settings for a while (e.g. show pictures, disable scripting, ???).

late at night
Tuesday, October 15, 2002

You don't have to write a script, use .reg files instead. With .reg files, you can enter stuff into the registry simply by double-clicking them.

Frederik Slijkerman
Tuesday, October 15, 2002

At first I was surprised by your demand to renounce windows (or even dialogs). Then it occurred to me that you're exactly right: the only function of the program is to flip a switch. The current switch position should of course be visualized in any way to the user, which you could do via changing the application's icon and then requesting a refresh of the desktop. You would use two icons, one visualizing the ON and one the OFF state.

That way you could have a link to the program on your friend's desktop, and after a restart (after e.g. he returns home) he could see from the program's icon if he should launch it before using his internet connection.

martin dittus
Monday, October 21, 2002

*  Recent Topics

*  Fog Creek Home