Web Analytics
   Register •   Forum Home •   FAQ      Login    
   Windows Forums Register
Donate a Dollar to Pay for Next Year’s Web Hosting It is currently Wed Dec 30, 2009 5:33 pm

All times are UTC - 5 hours [ DST ]


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to execute a .BAT every two minutes ?
PostPosted: Thu Mar 05, 2009 1:02 pm 
Offline
New Kid on the Block
New Kid on the Block
User avatar

Joined: Thu Mar 05, 2009 10:06 am
Posts: 4
Hi,
I need to execute automatically a very simple .BAT file every two minutes. Anybody can tell me how I can do ???

Thank you very much,

Fred Lombardi



 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Thu Mar 05, 2009 1:22 pm 
Offline
Site Admin
Site Admin
User avatar

Joined: Sun Mar 02, 2008 8:33 pm
Posts: 1470
Fred. Use scheduled tasks.

XP:
Start > Control Panel > Scheduled Tasks

Vista/7:
Start, type "sch", click Scheduled Tasks

Then add a scheduled task, follow the wizard and select the batch file you want to run every two minutes. Let me know if you need any help.

_________________
Learn how to customize and improve your PC.


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Thu Mar 05, 2009 1:40 pm 
Offline
New Kid on the Block
New Kid on the Block
User avatar

Joined: Thu Mar 05, 2009 10:06 am
Posts: 4
Thanks Rich,

I've tried Scheduled tasks, but it won't work for my needs, because the options are only

- every day
- every week
- every month
- only once
- at computer start-up
- at user log-in,

and none of them works for me, because I need the .bat to be executed every two minutes.

Any suggestion ?

Thank you again,

Fred Lombardi


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Fri Mar 06, 2009 2:04 am 
Offline
Site Admin
Site Admin
User avatar

Joined: Sun Mar 02, 2008 8:33 pm
Posts: 1470
Ah, I should have checked the forum this was in first. In Vista, you have the ability to run a task up to once a minute.

I've taken a look around, but I can't find a way to do this... I'll get back to you if I find something.

_________________
Learn how to customize and improve your PC.


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Sun Mar 08, 2009 2:43 pm 
Offline
New Kid on the Block
New Kid on the Block
User avatar

Joined: Thu Mar 05, 2009 10:06 am
Posts: 4
Thanks anyway.
Actually the .bat file does nothing more that pinging an ip address, that is, it issues the command:

PING <ip-address>.

Anybody knows if ther's some utility that issues the ping command every one or two minutes ??

Thanks in advance,

Fred


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Sun Mar 08, 2009 3:07 pm 
Offline
New Kid on the Block
New Kid on the Block
User avatar

Joined: Thu Mar 05, 2009 10:06 am
Posts: 4
Well actually I've found a way, although it's a bit tricky:

I've written the myping.bat file as follows

time /T >> mylog
ping -n 1 <ip-address> >> mylog
ping 127.0.0.1 -n 60 -w 1000 > nul
myping


The key is the
ping 127.0.0.1 -n 60 -w 1000 > nul
command: in this way I ping myself for 60 seconds, so the batch process basically waits 60 seconds !
And then at the end I recursively call the myping.bat program !

It's a bit tricky, and probably it consumes system resources, but for the time being it works.

Any better idea ?

Thanks in advance,

Fred


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Sun Mar 15, 2009 2:58 am 
Offline
Frequent Member
Frequent Member
User avatar

Joined: Sun Mar 15, 2009 2:25 am
Posts: 48
Here's a way to do it using the command line:

From Technet:
http://technet.microsoft.com/en-us/library/cc772785.aspx#BKMK_minutes

Code:
To schedule a task that runs every N minutes

Minute Schedule Syntax

schtasks /create /tn TaskName /tr TaskRun /sc minute [/mo {1 - 1439}] [/st HH:MM] [/sd StartDate] [/ed EndDate] [{/et HH:MM | /du HHHH:MM} [/k]] [/it] [/ru {[Domain\]User [/rp Password] | System}] [/s Computer [/u [Domain\]User [/p Password]]]
Remarks

In a minute schedule, the /sc minute parameter is required. The /mo (modifier) parameter is optional and specifies the number of minutes between each run of the task. The default value for /mo is 1 (every minute). The /et (end time) and /du (duration) parameters are optional and can be used with or without the /k (end task) parameter.

Examples
To schedule a task that runs every 20 minutes

The following command schedules a security script, Sec.vbs, to run every 20 minutes. The command uses the /sc parameter to specify a minute schedule and the /mo parameter to specify an interval of 20 minutes.

Because the command does not include a starting date or time, the task starts 20 minutes after the command completes, and runs every 20 minutes thereafter whenever the system is running. Notice that the security script source file is located on a remote computer, but that the task is scheduled and executes on the local computer.

[b]schtasks /create /sc minute /mo 20 /tn "Security Script" /tr \\central\data\scripts\sec.vbs[/b]


So copy that last line, change out the 20 for 2, enter what you want to call the script (replace Security Script) and then the path to the batch file (after the "/tr"). You can go check the task in the task scheduler afterwards to make sure it's there or run schtasks /query at a command prompt. And to delete it run schtasks /delete /tn "taskname" then hit "Y" to confirm.
:D

_________________
Image
Please don't ask and run...stick around for the answer to your question!


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Sat Apr 18, 2009 12:45 pm 
Offline
New Kid on the Block
New Kid on the Block
User avatar

Joined: Sat Apr 18, 2009 12:34 pm
Posts: 3
You want to PING an ip address every two minutes ? The following script in biterscripting will do it.

Code:
while (true)
do
    system PING <ip-address>
    sleep 120
done


Above sleeps 120 seconds inbetween PINGs. You can redirect output from PING to a file or a variable for further processing ( I am assuming you want to do something with, or do different things based on, the output of the PING. ) biterScripting has several commands that can help you easilty scan the output of the PING command (for example: get the count of lost packets, and do something based on lost packets, etc.)

To use the above script, download and install biterScripting by following instructions at http://www.biterscripting.com/install.html . It is free. Store the above script at, say, C:/X.txt. Call the script from biterscripting as follows.

Code:
script "C:/X.txt"


You can even invoke the above script (or any script) directly from a webserver using biterscripting.

Patrick


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Sun Apr 19, 2009 4:23 am 
Offline
Established Member
Established Member
User avatar

Joined: Sat Apr 11, 2009 12:20 am
Posts: 12
Easier way using task scheduler and keeping it simple. create a task to run daily and set it up to run your .bat file. when you are on the last page of the task set up check the "open properties when i click finish". on the dialog, change to the triggers tab, select the daily task and "edit". on the advanced properties section select "repeat task every", and set it up from there. this way works for me.


 Profile E-mail  
 Post subject: Re: How to execute a .BAT every two minutes ?
PostPosted: Sat May 02, 2009 10:54 am 
Offline
Highly Valued Member
Highly Valued Member
User avatar

Joined: Tue Aug 19, 2008 6:54 pm
Posts: 195
Location: New Jersey
You have to used the Task Scheduler

_________________
Image
  • @BobertBot
  • @bobertjustsaid
"Wise men speak because they have something to say. Fools speak because they have to say something"
--Plato


 Profile E-mail  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


© 2008-09 www.mintywhite.com | Rich Robinson