• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 958
  • Last Modified:

Automatic release and renew

I'd like to do a bat file to do ipconfig /release, then ipconfig /renew, but don't know how to write it so that it does step one (release), waits for it to release, then does step two (renew).
Any suggestions?
0
maharlika
Asked:
maharlika
  • 2
  • 2
2 Solutions
 
sda100Commented:
Hello maharlika

A batch file will wait for the last command to complete before starting the next.  So, simply:

ipconfig /release
ipconfig /renew

...in your batch file should do the trick.  Plain and simple!

Steve :)
0
 
OkigireCommented:
You can add "@echo off" as the first line too so you don't see the extra prompt.

I'm not sure if you know how to write a batch file, but it's literally this simple:
 - open up NOTEPAD
 - type in the commands (ipconfig......)
 - save it with a filename ending with  .BAT
...done!

Sometimes a batch file will stop working after it runs a command, such as 'ipconfig'.  It's unlikely in this case, but if it does, add a "CALL" command to the beginning of the line, so it would be:

@echo off
call ipconfig /release
call ipconfig /renew

...etc
0
 
Eric BCommented:
if you really need to wait 10 seconds between both, download from the resource kit the "sleep" command which is like unix. You can sleep for the number of seconds you want.
0
 
sda100Commented:
Hello again maharlika,

Who needs the resource kit?  Use the PING command instead.  Each ping takes 1 sec (by default).  So, to sleep for 10 secs:

ping -n 10 0.0.0.0 >nul

...but you don't need it.

Steve :)
0
 
Eric BCommented:
its called good programming/scripting practice!! :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now