General discussion

Locked

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 http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setdnsserversearchorder_method_in_class_win32_networkadapterconfiguration.asp

Thanks.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

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

Hi,
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.

Cheers!
~Sean

http://www.winnetmag.com/Windows/Article/ArticleID/20278/20278.html

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.

Back to Windows Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums