Merge two batch files (.bat) into one?

Home » Programming & Design » Merge two batch files (.bat) into one?
Programming & Design No Comments

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 click (no delay, any time,

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 click (no delay, any time, same file) – switch on;
• and so on, and so on (just clicking, without any other actions required).

Best Answer:

Peter: If you want no delay at all, then there's two ways: in the batch file, have two lines, with each of those commands in it. If you want it in a single line, do "ipconfig /release && ipconfig /renew". The && means that what follows is a second command that should only run if the first one was successful.

If you want a pause, you can put in a PAUSE statement, but that'll wait for you to press enter, not a click. There's no easy way to capture a click in a standard batch file.

Other answer:

Peter:
Doesn't work that way. A batch file will run from top to bottom every time. You need 2 separate files.
Laurence I:
you just need a "pause" inbetween so you have to press space bar. be aware that although you can do this release renew, what actually happens the other end is down to your ISP and it may not do anything until you have been idle for 5mins. so the release renew in quick succession may be pointless, as they are not obliged to do anything.
kainaw:
You are using one script. It is called ipconfig. The /release and /renew are command-line parameters sent to the script. You say you want to "click". Networking should be in your system tray. You can click on it to enable/disable networking as you like.

LEAVE A COMMENT