closing programs

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
closing programs

Post by Guest » Sat May 08, 2004 7:54 am

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.

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: closing programs

Post by frankiebaby » Sat May 08, 2004 5:51 pm

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!

Guest

Re: closing programs

Post by Guest » Sat May 08, 2004 11:55 pm

but how can you close another program, like internet explorer or something?

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: closing programs

Post by frankiebaby » Sun May 09, 2004 8:56 pm

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

Guest

Re: closing programs

Post by Guest » Mon May 10, 2004 4:25 am

thanks anyways

Post Reply