Is there a way to have 1 script that checks current IP settings (DHCP or Static), and then alternates to the other.
Currently I have one script to set DHCP, and another to set IP. I would like one script that looks at the current settings, and then switches to the other. In a perfect world it would have a pause telling the user which direction it is being switched.
These are what I am using so far.
Scrip 1
@echo Be sure Network Cable is unplugged and
@pause
netsh int ipv4 set address name="Local Area Connection" source=static address=10.38.xxx.xxx mask=255.255.255.xxx gateway=10.38.xxx.xx
netsh int ipv4 set dns name="Local Area Connection" source=static address=10.99.xx.xx register=primary validate=no
Script 2
netsh interface ipv4 set address name="Local Area Connection" source=dhcp
netsh interface ipv4 set dnsservers name="Local Area Connection" source=dhcp
@echo It may take a few moments for changes to take effect. You may close this window or
@pause
Thank you very much for your help.
You may use this interesting trick:
It is very important that the last line (set flipFlop=0) does NOT end in a new-line (CR+LF) characters. Copy-paste previous code, goto last character (Ctrl-End) and delete last characters with BackSpace if necessary so the last character is the "0" before save the file.
This trick works "only" for about 8180 times; after that, you must edit the file and reset the last line, so it looks like the original one again. If needed, additional code may be inserted so the program test by itself this condition and fix it automatically.