# Can a batch file turn a program off ?



## john1

Hi,

How can i make a little batch file,
that will turn off a (running) program ?

John


----------



## Squashman

Well I assume you are talking about doing it on Windows 98 because that is what is in your sig. I am not sure about the 9X systems but if it is NT/2000/XP you can use PSTOOLS.
http://www.sysinternals.com/ntw2k/freeware/pstools.shtml


----------



## john1

Hi LwdSquashman,

Thanks, yes its Win98se.

Turning a program on is easy enough,
this little bat file will run 'MSpaint'

*MSpaint
cls*

but i'm trying to turn off a running program,
using a bat file.

I'm hoping that this can be done as easily.

Regards, John


----------



## DaveBurnett

PC Answers has a program called PowerLaunch 1 on the CD this month. Its a full product and will allow launching and Closing applications.


----------



## john1

I am sort of looking at the instruction 'break'
but i don't think it would do what i want.

I want to make a bat.file that will turn off
a specific running program.

Still looking ....


----------



## Cosmic

The general command to stop or end something is "EXIT" in a batch file.
Would have to think it through a bit more. What type of program is it, how is it running? MS-DOS or Windows?

In general how does the program close normally? Either those commands or closing its window should work. EXIT should close an open MS-DOS prompt window.


----------



## john1

Hi Cosmic,

Thanks for that suggestion,
i have already looked at 'Exit' because that instruction
at first sight, appeared to be an instruction, but after
reading a bit about it, i don't think it is for closing
another program, i think its for closing the DOS window.

Unless theres more to it.

I do of course want to close the DOS window as well,
after the bat.file has closed the program.

The program i want to close is called 'SeeThru' it is
for making the icon legends have a transparent back.

I really did not think it would be difficult.

Regards, John


----------



## john1

Hi Cosmic,

Type of prog,
it's a small utility type of prog, freeware.
"SeeThru v1.0.2" can be got from:
http://website.lineone.net/~mstrong/apps.htm

It runs under Windows, i would guess win only.

It can be closed from 'file' > exit, or by
right clicking on the small icon in systray
and choosing 'Exit'.

Regards, John


----------



## Jedi_Master

Howdy john1...

I think kill.exe from the W98 reskit should be able to kill a task...

Kill.exe can be found here...

ftp://ftp.microsoft.com/services/technet/samples/ps/win98/reskit/DIAGNOSE/


----------



## john1

Thank you Jedi Master,

After fiddling about for a while to download this,
i finally found that a right click was the way to go.

I have downloaded 'Kill.exe' to my desktop,
however i'm afraid i don't know how to include it in
a batch file, or how to tell it which program to stop.

I shall start by putting it into the C: drive,
hope thats right.

John


----------



## Jedi_Master

Ya... doesn't matter where you put it, just make sure the location is in the Environment path ( c:\ allready should be in there )...

To get the command arguments try opening a DOS prompt navigate to where you put it and type in kill /? and see if it will give you the switches...

I'm not on a W98 machine right now to test it but you should be able to create a batch file something like this...

kill /( whatever the switch is to stop the program)c:\( the path to the program\the program name )...

Or...

kill c:\( the path to the program\the program name )...


----------



## john1

my attempt at a bat.file

trying it with Mspaint1
(i have two)

Doesn't turn it off though.


----------



## john1

Kill/?


----------



## Jedi_Master

Well...

The slashes are backwards "/" instead of "\"...

But I've got a W98 machine up and have been experimenting with this, and it looks like this will work ( although I haven't so far made it close the DOS window even with exit yet )...

I'm using notepad for an example...

C:\kill notepad
exit

Thiss is what I put in the batch file, don't use a path to the file name...


----------



## john1

Use TLIST

i dont have a program called TLIST ...


----------



## john1

Okay,
posts crossed.

So you're using notepad to test it on, yes ?


----------



## john1

close with cls as the last line


----------



## john1

C:\kill notepad
cls


----------



## john1

works ok with notepad.
Now to check it with 'SeeThru'


----------



## Jedi_Master

Ok...

With ms paint you will need to use the /f switch...

c:\kill /f mspaint1


----------



## john1

Ah,
i will try that,
although its 'SeeThru'
i want to turn off ...


----------



## john1

says its killed it
but it hasn't


----------



## Jedi_Master

TLIST.exe you can down from the ftp site for the W98 reskit...


----------



## Jedi_Master

Try...

C:\kill /f seethru


----------



## john1

C:\kill /f SeeThru

That works,
but now i dunno how to get rid of the bat ...
and the logo in systray lingers
till you put the cursor over it,
annoying but i can live with that.


----------



## john1

posts crossed again,
still trying to get the bat to go ....


----------



## Jedi_Master

john1 said:


> C:\kill /f SeeThru
> 
> That works,
> but now i dunno how to get rid of the bat ...
> and the logo in systray lingers
> till you put the cursor over it,
> annoying but i can live with that.


That's the same thing I'm seeing, doing some more research, but we're close


----------



## Jedi_Master

Ahhh...

Got it...

In the Dos window, click on the "MSDOS" logo in the upper left corner of the window - Properties - click to check "Close on exit" - Apply - OK, it will add another Icon to the desktop...

See if that works...


----------



## john1

For some crazy reason putting cls twice gets rid of the bat.

C:\kill /f SeeThru
cls
cls


----------



## Jedi_Master

I'm sorry...

In the Dos window, click on the "MSDOS" logo in the upper left corner of the window - Properties - Program tab - click to check "Close on exit" - Apply - OK, it will add another Icon to the desktop...

See if that works...


----------



## john1

well it did ...
now it doesn't

I'm trying to do what you said with 'close on exit'

no luck yet


----------



## john1

Couldn't get that 'close on exit' to work
without another logo on the destop,
and the bat didn't go away.

but i found that one cls will do it,
i had to delete the bat and do it again,
dunno why,
but it works now.

Except for the lingering logo in systray.
There may be no way to lose that,
i will have to live with it.


----------



## Jedi_Master

john1 said:


> Couldn't get that 'close on exit' to work
> without another logo on the destop,
> and the bat didn't go away.
> 
> but i found that one cls will do it,
> i had to delete the bat and do it again,
> dunno why,
> but it works now.
> 
> Except for the lingering logo in systray.
> There may be no way to lose that,
> i will have to live with it.


Hmmmm...

All I did was click on the logo - properties - and click to check the "Close on exit" box, what this does is creates a .pif file ( the extra file on the desktop ) in which you will need both .bat and .pif file to run it ( haven'd found a .pif editor in W98 like you have in W3.1)...

Apperently when you right click on the .bat file - Properties - that's the .pif editor...



> Couldn't get that 'close on exit' to work
> without another logo on the destop,
> and the bat didn't go away.


What you could do is move the .bat file somewhere other that the desktop, then create the .pif file ( by doing the steps outlined in my pervious post of clicking on the "Close on exit" box ) then move the shortcut to the desktop...

Mine isn't showing up in the System tray either...


----------



## john1

Thats good, yes, create the .pif somewhere else !
Obvious really i suppose.

In my case, i will use the folder holding the program
that i am trying to deal with, SeeThru.

You say you have no logo in the systray,
maybe you're still checking it out with notepad ?

If you download seethru (for transparent icon words)
it works OK, but leaves a mini icon in systray.

The only way i can see of to get rid of that little icon
in systray is to shut the program down.
Fortunately, that still leaves the desktop icons with a
transparent background.

So my intention was to run a small .bat from the startup
to shut down seethru, but that doesn't seem to work.
Probably because i was using startup to start seethru
as well as the bat to stop it.

So i suppose i would need to have a small interval
between starting and stopping for it to work.

There may be a completely different way to get make the
icons have clear words, maybe some sort of registry
hack ?

Otherwise i will have to have a think ....

The bat i've ended up using is: *
C:\kill /f SeeThru
cls *

One minor thing, i'm not sure if the
cls instruction actually closes the .bat
or if it just stops displaying it on screen.

Might try using 'process viewer' to check that,
or maybe 'Cnt-Alt-Del' would show it ... ?

Regards, John


----------



## john1

It has just occurred to me
that maybe a .bat file could be made which
would run seethru,
wait for 1 second,
then stop (kill) seethru.

This would combine the start, wait, and stop
into one .bat file.

This might be one possible way to do this.

John


----------



## john1

maybe fifteen seconds,
i could reduce it a bit at a time ...


----------



## john1

I found this ...
but i don't know if it will cause a bat
to wait, then continue ....
the explanation seems vague,
could someone explain, maybe ...

http://malektips.com/dos0017.html


----------



## DrewGBowman

john1 said:


> I found this ...
> but i don't know if it will cause a bat
> to wait, then continue ....
> the explanation seems vague,
> could someone explain, maybe ...
> 
> http://malektips.com/dos0017.html


use the "pause" comand it will display the message "press any key to continue..."


----------

