Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1832
  • Last Modified:

How to close a program using a batch file? Time delay too?

Hi.

I have a batch file that starts a program
in Win 98SE.

Now, how can I make the batch file close
this program?

More exact...how can I make the batch file
close this program after "x" amount of time?

If not possible, can I use some basic scripting
to achieve this, if so how?

Thanks a bunch,

Tim
0
happycat
Asked:
happycat
  • 3
  • 3
  • 2
  • +1
1 Solution
 
sunray_2003Commented:
Tim,

Check this

http://www.experts-exchange.com/Operating_Systems/WinXP/Q_20720235.html

Try to use other options of the command to get time delayed closing

Sunray
0
 
happycatAuthor Commented:
Thanks. However both TSKILL Command and TASKKILL are not recognized commands on my system (Win 98SE)

Is there a way to upgrade the commands recognized or am
I limited to what Win 98SE has for DOS commands?

0
 
CrazyOneCommented:
Well there isn't any thing like a resource kit for Win98 like there is for NT and up. Quite frankly I don't think you can do it through a batch file I beleive you would need to use VB scripting or develop an actual program to do it.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CrazyOneCommented:
Programically I do things like this to close a program.

Example to close the MS heart program I know the title of the window is "The Microsoft Hearts Network"

so I do this
SendMessage(FindWindow('The Microsoft Hearts Network', nil), WM_CLOSE, 0, 0);


If you know that class name of the window then you can us it to do the same thing. In this case I know the class name is "AfxFrameOrView42u:

so I do this
SendMessage(FindWindow('AfxFrameOrView42u', nil), WM_CLOSE, 0, 0);


These examples are from my Windows XP but the idea is the same.
0
 
happycatAuthor Commented:
Thanks All.

I just figured out a way to do this in Win98.

There is a freeware "Process Viewer"
for Windows NT/2000/XP and 95/98/Me at:

http://prcview.com  or
http://www.xmlsp.com/pview/prcview.htm
http://www.xmlsp.com/pview/PrcView.zip

or

http://www.teamcti.com/pview/
http://www.teamcti.com/pview/PrcView.zip

It's as simple as two lines in a batch file like this:

start pv.exe
pv -k exampleprogram.exe

where -k is to kill and if desired:

pv -kf exampleprogram.exe

where the f is for forcing the kill

I'll try to figure out ways to manipulate the timing as desired.

Is there a way I can repeat certain lines of a batch file
without retyping the same code?

...for example something to create a loop from one line through
another for "x" amount of times?

Anyway here is more of the info:

PrcView v 3.7.2.4 command line utility by Igor Nys
Usage: pv -[<MODE>] -[<OPTIONS>] <ARGUMENTS>...-[<OPTIONS>]

support@prcview.com
or contact directly at igornys@writeme.com

0
 
Egoslayer1Commented:
use 'for' command to repeate lines, FOR us weak in 98, but immensly powerful in NT and newer...still FOR can do a lot of things if you get creative, even under 98

use sleep to pause thing for a set number of seconds...sleep is standard on newer windows OS's, but you can find free versions on the internet for 98, if you can't locate them, email me at Egoslayer1@hotmail.com and I'll send you a copy.
0
 
Egoslayer1Commented:
you can also use IF to loop a section of batch file and break out after a fixed number or  time, or rather when a variable equals the right thing... something like

@echo off

set X=1
:start
echo %X%
if "%X%" EQU "20" goto end
set /A X=%X%+1
echo %x%
goto start

:end
echo done
pause

slight syntax aside, would repeat everythign between ":start" and "goto start" 20 times, which in this case is echo'ing the variable %X%.

IF will often get you what you need, but FOR is made specifically for that, and is thus frequently cleaner.

ES
0
 
happycatAuthor Commented:
Thanks Egoslayer1.

I'd like to give you the points since that was helpful for my second question, which I apologize for not making a seperate question
to have the topic stay focused.

So to have the answer for this question be
appropriate for people searching...

could you copy parts my previous post for closing progs in batch, with your other comments about FOR and IF, and by all means any other alternatives for closing progs in batch files.

Plus I also found a shareware utility called
"Hold!"

usage [hold!] [seconds] [option]
option c is to show countdown.

http://www.filelibrary.com/Contents/DOS/51/5.html
http://www.filelibrary.com:8080/cgi-bin/freedownload/DOS/h/51/hold!.zip

Works like a charm.

Also, another way to create loop (however infinite) is found here:

http://www.experts-exchange.com/Operating_Systems/Win98/Q_20774606.html
0
 
Egoslayer1Commented:
You can close a program in 98 with PrcView. I'm sure there are other programs out there to do the same thing. PrcView is neat since it works on most any windows version.

http://www.teamcti.com/pview/prcview.htm

also the aforementioned sleep program available for free from MS, it comes in some of the resource kits, the one for 2003 is here...
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

Sleep works just like the hold program you found, except sleep doesn't have a countdown option, so hold might be better.

ES
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now