up vote 4 down vote favorite
2

I have a batch file:

arp -s 192.168.1.254 xx-xx-xx-xx-xx-xx
ipconfig /flushdns

How can I do these two commands on Windows XP, every 10 seconds?

flag
3  
You can use Windows Scheduled Tasks to get it down to once a minute. You might have more luck at superuser.com. – Jay Riggs Nov 7 '09 at 0:18

migrated from stackoverflow.com

7 Answers

up vote 8 down vote
:top
arp -s 192.168.1.254 xx-xx-xx-xx-xx-xx
ipconfig /flushdns
sleep 10
goto top

Edit: As mentioned in the comments, SLEEP won't be available in a normal install. You'll need something like the Windows 2003 Resource Kit, or some other trick to simulate it (the ping trick Bruno mentions), and notes to do so can be found here.

link|flag
5  
sleep isn't included by default. You need the resource kit or something to get this? – marcc Nov 7 '09 at 0:19
What exactly do I need? – steven Nov 7 '09 at 0:21
It isn't? I could've sworn it was something I could count on, but I guess like choice it might not be included by standard. I'll look into it more. – Doug Kavendek Nov 7 '09 at 0:21
What is the link to this resource kit? – steven Nov 7 '09 at 0:23
1  
There's no need to install anything else on windows to "fake" a sleep command. Take a look at my answer for an example. – Bruno Reis Nov 7 '09 at 0:29
show 4 more comments
up vote 8 down vote

Try this one:

:loop
arp -s 192.168.1.254 xx-xx-xx-xx-xx-xx
ipconfig /flushdns
ping localhost -n 11 > nul
goto loop

The ping command will execute for 10 seconds, and all the output will be redirected to the NUL device, meaning that you will see no output from the ping command. It works indeed as a "sleep" command would.

link|flag
I exclaimed PING! when I saw the question ;) – Mehmet Ergut Nov 7 '09 at 0:34
Somehow I knew you would! – Bruno Reis Nov 7 '09 at 0:36
up vote 2 down vote

Install Cygwin which will make sleep and cron available to you (among other things).

link|flag
1  
Overkill for what he is asking! – Bruno Reis Nov 7 '09 at 0:31
up vote 1 down vote

You could set up a Windows service to run your batch file.

link|flag
1  
How? Example please? – steven Nov 7 '09 at 0:18
up vote 1 down vote

Cheat:

Use this command to pause the batch for 10 seconds

choice /n/t:c,<10>/c:cc

Now, place it in a never ending loop in the batch and voilĂ !

link|flag
1  
Or, if you want, download the resource kit or write a simple prog to sleep 10. My method however, will mean you can move it to another machine without having to download more software again. – Dan McG Nov 7 '09 at 0:22
I didn't think choice came with XP and later, or at least I haven't seen it on any recent installs. – Doug Kavendek Nov 7 '09 at 0:29
1  
I'm running vanilla Vista Home Premium on this laptop and it works fine. – Dan McG Nov 7 '09 at 0:35
up vote 0 down vote

More precise solution ping unexistent host once and set timeout

ping 1.0.0.0 -n 1 -w 10000 >nul

But it generate parasite traffic

link|flag
up vote 0 down vote

Thanks Bruno Reis. your scripts worked..

link|flag

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.