Re: Simple Script file - I think:(

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Sethalon (Sethalon_at_N-O-S-P-A-Mearthlink.net)
Date: 02/28/04


Date: Sat, 28 Feb 2004 15:55:26 GMT

On Sat, 28 Feb 2004 10:09:46 +0000, Merlin wrote:

> I have around 20 sites, each site has a different IP rang and all PCs are
> static IP (No DHCP), its a bit of a pain when i have to keep changing the
> IP, Gateway, DNS and other IP settings on my Laptop.
>
> I was wondering if I could write a script file which asked me what site i
> was at i clicked the site and it automatically changed all my IP settings?
> this would have to work on Windows 2000 or XP.

You certainly could.

You would need to have some kind of simple DB to hold the
information for each network. However, the utility NETSH.EXE is your
friend.

NETSH INTERFACE IP SET ADDRESS

Usage: set address [name=]<string>
       [[source=]dhcp |
        [source=] static [addr=]IP address [mask=]IP subnet mask]
       [[gateway=]<IP address>|none [gwmetric=]integer]

Name= is the name of the adapter in Network Connections.

Usage: set dns [name=]<string> [source=]dhcp|static [addr=]<IP address>|none
             [[register=]none|primary|both]

So you could run these two commands:

netsh int ip set add name="Local Area Connection" source=static \
addr=192.168.0.102 mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1
netsh int ip set dns name="Local Area Connection" source=static \
addr=192.168.0.2

Then you just bind them up in a script to handle the DB and use
WScript.Run to execute them. Of course if you were really lazy, you could
just use a batch file. Use a section for each network. Jump to the
section for the passed parameter. You could even make use of this:

    SET /P variable=[promptString]

set /p NetName="Which network are you on?"
if %NetName="" then goto end
goto %NetName

BTW, this fun is one of the reasons that DHCP was invented.

Seth



Relevant Pages

  • Re: Error Message
    ... On the General tab in the Temporary Internet Files Folder, ... Click on "LAN Settings" and make sure everything is blank, ... Network settings ... IP address automatically", click on the DNS tab, disable DNS here, click ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: IE cant connect to any sites
    ... On the General tab in the Temporary Internet Files Folder, ... Click on "LAN Settings" and make sure everything is blank, ... Network settings ... IP address automatically", click on the DNS tab, disable DNS here, click ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: IE connection issue
    ... Click on "LAN Settings" and make sure everything is blank, ... Network settings ... IP address automatically", click on the DNS tab, disable DNS here, click ... To restore damaged or corrupt Winsock files. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Page cannot be found
    ... On the General tab in the Temporary Internet Files Folder, ... Click on "LAN Settings" and make sure everything is blank, ... Network settings ... IP address automatically", click on the DNS tab, disable DNS here, click ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: sasser virus; now I get page error every time I try to access the web and fail
    ... On the General tab in the Temporary Internet Files Folder, ... Click on "LAN Settings" and make sure everything is blank, ... Network settings ... IP address automatically", click on the DNS tab, disable DNS here, click ...
    (microsoft.public.windows.inetexplorer.ie6.browser)