Page 1 of 1

closing programs

Posted: Sat May 08, 2004 7:54 am
by Guest
How could you close a program after a certain amount of time? Can't explain it too well; so here's the code that I think may work:

OPEN filename.exe for INPUT as #1
SLEEP 2000
CLOSE <somethin' here>

And one more thing: For Windows XPs' disk defragmenter, you can get it to start by doing this:

taco$ = "thepath.exe /start"
SHELL taco$

Right? Thanks.

Re: closing programs

Posted: Sat May 08, 2004 5:51 pm
by frankiebaby
well, that close you put in there simply closes the file you opened. To end the program, use END. Also, you may not want to use SLEEP 2000, becuase sleep waits for 2000 seconds OR a keypress, whichever comes first.

Instead, use something like this

T! = TIMER
DO: LOOP UNTIL TIMER > T! + 2000

this will wait approximately 2000 seconds, unless those
2000 seconds span midnight, as TIMER returns the seconds past midnight.

to midnight proof it:
TIMEPASS% = 0

T% = INT(TIMER)
DO
IF INT(TIMER) <> T% THEN TIMEPASS+ TIMEPASS + 1
LOOP UNTIL TIMEPASS = 2000

this simply checks to see if the seconds are different, and if they are, count one second. Hope this helps, and happy programming!

Re: closing programs

Posted: Sat May 08, 2004 11:55 pm
by Guest
but how can you close another program, like internet explorer or something?

Re: closing programs

Posted: Sun May 09, 2004 8:56 pm
by frankiebaby
well, you cant quite do that through DOS that i kno of... you'd have to call a 'helper' program written for windows i think, like one that you pass in the program name to kill, and then it kills it. To close a window would require the use of windows api 's

Re: closing programs

Posted: Mon May 10, 2004 4:25 am
by Guest
thanks anyways