General discussion


VBScript - Static to DHCP & Back again

By Joshua1 ·
I've found a script that will help me move a computer from DHCP to static and back. I have a user who travels to multiple locations, all DHCP enabled except 1. The only problem is, this script does not clear the gateway entry when it switches back to dhcp. So the static gateway stays put. Can anyone provide me with code to clear the gateway so that the address provided by DHCP will be used? I've tried several variations, but I'm not very good at scripting. I've already looked at


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by Kinetechs In reply to VBScript - Static to DHCP ...

You can use Network Command Shell (netsh) from the command line with Win 2k and later. Here's a link to an article showing how. Remember to remove spaces from the URL.


Collapse -

by Joshua1 In reply to VBScript - Static to DHCP ...

Can you show how to incorporate the Command Line commands into vbscript? Or how to call the batch file from within the VBS file?

That's already what I'm doing as a workaround: they run the vbs for one, and run a batch for another. If I can get it all into a vbs, then the script can tell which way to go - to DHCP or to Static - based on what the current settings are. Right now, the users have to know if they need to have static IP configurations or if they need to be on DHCP. Simple stuff in IT...not so simple for tech-nots.

Related Discussions

Related Forums