-1

I have two .bat files in use to toggle my Internet connection:

1) "ipconfig /release" (to switch off)

2) "ipconfig /renew" (to switch on)

Could somebody please rewrite it, so I can use ONE single file instead of two?

Specifically:

  • one click - switch off;
  • another one (no delay, any time, same file) - switch on;
  • and so on, and so on (just clicking, without any other actions required).
  • Please read the entire [tour page](http://stackoverflow.com/tour) and learn how this site works! – aschipfl Sep 21 '16 at 15:29
  • Please note that https://stackoverflow.com is not a free script/code writing service. If you tell us what you have tried so far (include the scripts/code you are already using) and where you are stuck then we can try to help with specific problems. You should also read [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – DavidPostill Sep 21 '16 at 16:49

1 Answers1

1

This uses a toggle file in the batch file directory to implement the behaviour.

pushd
if exist __toggle__.txt (
    del __toggle__.txt
    ipconfig /renew
) else (
    echo. > __toggle__.txt
    ipconfig /release
)
FloatingKiwi
  • 4,408
  • 1
  • 17
  • 41