Sorry, I didn't get you, but can you please clarify more, give me example of your problem
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
you should have a method take a string as a parameter and execute it as command like
void Execute(char* command)
{
system (command)
}
and infinite loop in another thread let me write the pesudo code for it
for( ; ; )
call Execute stop this thread for 10 seconds
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
Well since you seem to be using windows, there are already a couple of ways built in to do this.
1. Use the 'at' command
$ at /?
The AT command schedules commands and programs to run on a computer at
a specified time and date. The Schedule service must be running to use
the AT command.
AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
[ /EVERY:date[,...] | /NEXT:date[,...]] "command"
\\computername Specifies a remote computer. Commands are scheduled on the
local computer if this parameter is omitted.
id Is an identification number assigned to a scheduled
command.
/delete Cancels a scheduled command. If id is omitted, all the
scheduled commands on the computer are canceled.
/yes Used with cancel all jobs command when no further
confirmation is desired.
time Specifies the time when command is to run.
/interactive Allows the job to interact with the desktop of the user
who is logged on at the time the job runs.
/every:date[,...] Runs the command on each specified day(s) of the week or
month. If date is omitted, the current day of the month
is assumed.
/next:date[,...] Runs the specified command on the next occurrence of the
day (for example, next Thursday). If date is omitted, the
current day of the month is assumed.
"command" Is the Windows NT command, or batch program to be run.
2. From the control panel, choose "Scheduled Tasks" then "Add Scheduled Task" and follow the prompts.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
while(true)
{
system("<yourcommand here>");
Sleep(90000);//have to include windows.h I think
}
Sturm
Veteran Poster
1,079 posts since Jan 2007
Reputation Points: 343
Solved Threads: 24
hmm... but what i mean is in the command prompt i tpye in C:/programfiles/blahblahblah so i hit enter. it opens the .exe. So when i hit the arrow up botton it has the same cmd in it.. so what i wanna do is have that arrow go up and exeute it every 90 seconds... so how would i do that?
.
You can't do that directly from the cmd prompt like you described unless you use a scheduler and have it run the command every so often as described by Salem in an earlier post.
The other alternative is to execute the program from the cmd prompt just once and have it do its stuff repeadetly forever -- using loops, something like this: [edit]which is nearly the same as Sturm posted[/edit]
#include <windows.h>
int main()
{
for(;;)
{
// execute some code here, not shown
do_something();
// wait one second
Sleep(1000);
}
return 0;
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
In your Include directory, if you don't see it, go and set it from your IDE settings->Include Directory and then set the path.
Ramy Mahrous
Postaholic
2,196 posts since Aug 2006
Reputation Points: 480
Solved Threads: 276
Perhaps it would be a good idea to first establish which C++ compiler you have.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
just use Ancient Dragon's code but replace Sleep(1000) with Sleep(90000).
Sturm
Veteran Poster
1,079 posts since Jan 2007
Reputation Points: 343
Solved Threads: 24
Hey can anyone tell me how to make a program that i can have a cmd in the cmd to exacute over and over waiting 1 minute each time?
just use Ancient Dragon's code but replace Sleep(1000) with Sleep(90000).
one minute is 60000 milliseconds, not 90000.
Where to find windows.h on your hard drive depends on what compiler you have. Many compilers don't have it at all and you have to download the (free) Microsoft Windows Platform SDK from Microsoft web site. Its pretty large so if you have a slow internet connection you might want to get it on CD for nominal cost.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Hey can anyone tell me how to make a program that i can have a cmd in the cmd to exacute over and over waiting 1 minute each time?
Hey sorry.. i dont fallow too much i am new to C++ so lets say i wanted to open C:/programfiles/bh/hed.exe
and open it every 90 secs what would i do??
one minute is 60000 milliseconds, not 90000.
I know.
Sturm
Veteran Poster
1,079 posts since Jan 2007
Reputation Points: 343
Solved Threads: 24
K i D\L it soo i see it in the HD but i have to put it anywhere? Its red so icant compile it.. how do i fix it?
Where is it on your hard drive? On my hard drive its in include directory with a lot of other windows header files and libraries. windows.h is not a stand-alone header file but requires several other windows headers also. I have no idea whatK i D\L is, but whatever it is it will probably recognize the /I option flag to identify the full path where include fles are located.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343