Need help making a program

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2007
Posts: 1
Reputation: starjsjwars is an unknown quantity at this point 
Solved Threads: 0
starjsjwars starjsjwars is offline Offline
Newbie Poster

Need help making a program

 
0
  #1
Sep 16th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Need help making a program

 
0
  #2
Sep 16th, 2007
Sorry, I didn't get you, but can you please clarify more, give me example of your problem
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 7
Reputation: starjsjswars2 is an unknown quantity at this point 
Solved Threads: 0
starjsjswars2 starjsjswars2 is offline Offline
Newbie Poster

Re: Need help making a program

 
0
  #3
Sep 16th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Need help making a program

 
0
  #4
Sep 16th, 2007
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.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 7
Reputation: starjsjswars2 is an unknown quantity at this point 
Solved Threads: 0
starjsjswars2 starjsjswars2 is offline Offline
Newbie Poster

Re: Need help making a program

 
0
  #5
Sep 16th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Need help making a program

 
0
  #6
Sep 16th, 2007
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
  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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 7
Reputation: starjsjswars2 is an unknown quantity at this point 
Solved Threads: 0
starjsjswars2 starjsjswars2 is offline Offline
Newbie Poster

Re: Need help making a program

 
0
  #7
Sep 16th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 1,066
Reputation: Sturm is on a distinguished road 
Solved Threads: 24
Sturm's Avatar
Sturm Sturm is offline Offline
Veteran Poster

Re: Need help making a program

 
0
  #8
Sep 16th, 2007
  1. while(true)
  2. {
  3. system("<yourcommand here>");
  4. Sleep(90000);//have to include windows.h I think
  5. }
"Hey ass, don't hijack my thread. This is serious." -JoshSCH
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,585
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1487
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Need help making a program

 
0
  #9
Sep 16th, 2007
Originally Posted by starjsjswars2 View Post
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]

  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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 7
Reputation: starjsjswars2 is an unknown quantity at this point 
Solved Threads: 0
starjsjswars2 starjsjswars2 is offline Offline
Newbie Poster

Re: Need help making a program

 
0
  #10
Sep 17th, 2007
where do i find the windows.h?

sorry lol i am big time noob huh?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC