Re: Simple Script file - I think:(
From: Sethalon (Sethalon_at_N-O-S-P-A-Mearthlink.net)
Date: 02/28/04
- Next message: Michel Gallant: "Re: FYI - New WinZip vulnerability"
- Previous message: krisrajz: "Existence of Application"
- In reply to: Merlin: "Simple Script file - I think:("
- Messages sorted by: [ date ] [ thread ]
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
- Next message: Michel Gallant: "Re: FYI - New WinZip vulnerability"
- Previous message: krisrajz: "Existence of Application"
- In reply to: Merlin: "Simple Script file - I think:("
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|