Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping and running other applications from your application?

Status
Not open for further replies.

Sherak

Programmer
Sep 1, 2003
83
GB
Hi,

I have created a program which runs on startup (program A) and closes on shutdown. This program gets its parameters from the registry and I have seperate program to modify these parameters (Program B). I want to add the feature to program B which would allow me to stop or start program A but I have no idea how to do it. I'd be most grateful to anyone who can point me in the right direction...

Thanks.......
 
Starting a program is easy. Look at the FAQ for this forum on "Execute (spawn) a program." I would suggest faq101-1952, faq101-1953, or faq101-1954.

Stopping the program is a little tricky since I don't understand how your program knows when to stop. Can you give us more details on that?

James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Hi James,

Thanks for that. Details on the program I would like to close are as follows:

It is a simple file moving program it monitors a directory and if a file appears there with a certain extention it moves the file to another directory.

The program is a simple exe that only relies on parameters from the registry. It starts up and shuts down with Windows because I added a program shortcut to HKEY_LOCAL_MACHINE/SOFTWARE/MICROSOFT/WINDOWS/CURRENTVERSION/RUN

the program is called FileMover.exe and if I need to stop it I can do so through task manager (ctr/alt/del) I just select FileMover.exe from the proces list and click end process, this is fine for me but now some people is other departments want to use it and they dont have access to the task manager, nor would I trust them in there ;-)

So yeah I would just like to add the option to stop and start the process from the configuation utility (which is another basic exe that just allows the user to modify the parameters stored int he registry through a visual interface.
 
It can be done but I've always used the easy way out. ;-) First, go to Sysinternals web site and download PsKill ( I use this program to stop other programs. As long as you don't resell this program you're OK with copyright, etc.

I call this program via CreateProcess or its cousins (see above). I supply the name of the program to PsKill just like the instructions say.

Maybe someone else can explain how to write your own program to do the same as PsKill but like I said, I've always taken the easy way out.

If no one posts an answer here, I'll look around for a simple method to kill a program.

James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Thanks again, I would like to avoid using a third party in this case, especially seeing as the program is being used in a comercial enviroment.

This said I dont know whilst reading your thread an ingenius idea just popped into my head which will work a treat :) I think it must have ben your refference to "Easy ways out" somtimes I tend to overcomplicate things ;)

like I said in the above thread, the file mover monitors certain paremeters held in the registry which can be changed on the fly with the cfg utility. In the a similar way to a watchdog timer I will place a value in the registry called 'IsRunning' and get the program to monitor this value at a timed event, if the value is true it will go on as normal, if it is false it calls Application->Terminate().. I will have to do some jiggery pokery to make sure it doesnt affect other areas but Its simpler than workign out how to kill processes :)

Thanks for the inspiration :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top