简体   繁体   中英

ipconfig: merge two batch files (.bat) into one

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).

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
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM