943,962 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1715
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 16th, 2007
0

Need help making a program

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starjsjwars is offline Offline
1 posts
since Sep 2007
Sep 16th, 2007
0

Re: Need help making a program

Sorry, I didn't get you, but can you please clarify more, give me example of your problem
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 16th, 2007
0

Re: Need help making a program

hey thanks ok when i am in the command propmt i tpye in a command .. so then i wanna do this command over and over ever 1 min so how do i do that? and make it go non stop.

thanks for repliey
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starjsjswars2 is offline Offline
7 posts
since Sep 2007
Sep 16th, 2007
0

Re: Need help making a program

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
Last edited by Ramy Mahrous; Sep 16th, 2007 at 2:45 am.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Sep 16th, 2007
0

Re: Need help making a program

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??

sorry i am a newbie
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starjsjswars2 is offline Offline
7 posts
since Sep 2007
Sep 16th, 2007
0

Re: Need help making a program

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
C++ Syntax (Toggle Plain Text)
  1. $ at /?
  2. The AT command schedules commands and programs to run on a computer at
  3. a specified time and date. The Schedule service must be running to use
  4. the AT command.
  5.  
  6. AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
  7. AT [\\computername] time [/INTERACTIVE]
  8. [ /EVERY:date[,...] | /NEXT:date[,...]] "command"
  9.  
  10. \\computername Specifies a remote computer. Commands are scheduled on the
  11. local computer if this parameter is omitted.
  12. id Is an identification number assigned to a scheduled
  13. command.
  14. /delete Cancels a scheduled command. If id is omitted, all the
  15. scheduled commands on the computer are canceled.
  16. /yes Used with cancel all jobs command when no further
  17. confirmation is desired.
  18. time Specifies the time when command is to run.
  19. /interactive Allows the job to interact with the desktop of the user
  20. who is logged on at the time the job runs.
  21. /every:date[,...] Runs the command on each specified day(s) of the week or
  22. month. If date is omitted, the current day of the month
  23. is assumed.
  24. /next:date[,...] Runs the specified command on the next occurrence of the
  25. day (for example, next Thursday). If date is omitted, the
  26. current day of the month is assumed.
  27. "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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Sep 16th, 2007
0

Re: Need help making a program

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?

thanks alot like i said i am new to the whole programing stuff.. I am a 3d arist but this is somthing i wanted to pick up for along time.. thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starjsjswars2 is offline Offline
7 posts
since Sep 2007
Sep 16th, 2007
0

Re: Need help making a program

C++ Syntax (Toggle Plain Text)
  1. while(true)
  2. {
  3. system("<yourcommand here>");
  4. Sleep(90000);//have to include windows.h I think
  5. }
Reputation Points: 343
Solved Threads: 24
Veteran Poster
Sturm is offline Offline
1,067 posts
since Jan 2007
Sep 16th, 2007
0

Re: Need help making a program

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]

C++ Syntax (Toggle Plain Text)
  1. #include <windows.h>
  2. int main()
  3. {
  4. for(;;)
  5. {
  6. // execute some code here, not shown
  7. do_something();
  8. // wait one second
  9. Sleep(1000);
  10. }
  11. return 0;
  12. }
Last edited by Ancient Dragon; Sep 16th, 2007 at 7:50 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Sep 17th, 2007
0

Re: Need help making a program

where do i find the windows.h?

sorry lol i am big time noob huh?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
starjsjswars2 is offline Offline
7 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Print
Next Thread in C++ Forum Timeline: problem implementing BFS using string vector





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC