how can I terminate a program from command script?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

hemlock

Thread Starter
Joined
Aug 29, 2002
Messages
9
I need to terminate a program running under Windows 2000 Professional in a cmd script, prior to shutting down the system in the event of a power outage. Since the powe outage may come when the system is unattended, I need to write a script to cause the program to exit.

Is there a way to do this in Windows 2000? Or a utility that will perform this function?

Any suggestions are appreciated.
 
Joined
Aug 17, 2001
Messages
7,486
Is the Computer going to shut down properly? Do you have a UPS? How would the script be called? Group Policy Machine shutdown script?
I know it can be done in VB. I bet it can be done in VBS. The VB code I have allows me to close any running program if I know the Window Title. I am new to programming. I know even less VBS than that. I do know you cannot close a program using the command prompt. You can force all programs to close and shut down windows. At least you can in Win9x. But the programs are not closed properly that way.
 

hemlock

Thread Starter
Joined
Aug 29, 2002
Messages
9
Is the Computer going to shut down properly? Do you have a UPS? How would the script be called? Group Policy Machine shutdown script?

The system is on a UPS. Windows 2000 is running in Vmware running in a Linux box. The way I imagine it will be shutdown is the Linux OS will detect the UPS running on battery, create a special file on linux server, a scheduled task in the Windows 2000 "machine" (it's a virtual machine running in Vmware) will run every minute or so & check for the shutdown file, then if present proceed to shutdown the programs running in Win2k, probably set another special file, then shutdown Win2k, then the Linux script will shutdown Vmware, then shutdown Linux. It's actually a bit more convoluted because of course it would need to clear the shutdown files and then shutdown Linux machine 1 (running Vmware & Win2k), then shutdown Linux file server. :)

I'm new to Windows 2000, so I don't know what Group Policy Machine shutdown script is. Can you expand a bit?

http://msdn.microsoft.com/archive/default.asp?url=/ARCHIVE/en-us/dnarvbtips/html/msdn_msdn36.asp has something about terminating application, but it talks about window handle.

I used to do programming (asm, C, C++) but never in Windows & nothing in VB, so you're way ahead of me. I think that the cmd processor can run vb script, but since I don't know VB or VBS I'd hope there was another way.

Another article in MS seemed to say that the normal shutdown process would attempt to terminate normally any running programs, but I'm not sure that that is what happens when one uses psshutdown (http://www.sysinternals.com/ntw2k/freeware/psshutdown.shtml). Or do you know another way to tell Win2000 to shutdown?
 
Joined
Aug 17, 2001
Messages
7,486
It appears you need some really professional advice from someone who is familiar with win2k. Possibly a System Administrator. I use XP and 98 SE on a single user computer. I do not want to do any damage here.

Group Policy is a great tool. It is very powerful. You can set a script to run each time windows Shuts down. Among other things.

Going to start>run and typing:
gpedit.msc will open the console. You can manage things from there.

Under Computer Configuration>Windows Settings>Scripts
Select shutdown and add a script.

If I were to write a batch file calling an exe, that would run, I believe. But first you would have to start the actual shutdown process.

If I am reading this correctly you want to start an organized Shutdown of Windows. And have all the running programs close in an organized manner. Having all information written from the cache etc. Registry changes recorded properly......



Closing a window or shutting down a process is not the same as properly closing down a program. When you normally shut down, what is the sequence of events? Do you have to close the running background tasks separately first? Or do they get the shutdown call from Windows and close themselves? Having the UPS gives you the luxury of having that extra time to allow a proper shutdown.

Using windows Handles is like using task Manager and ending a process. All windows both visible and invisible are assigned a handle. Finding that handle and sending a message using the API will close that particular Window. But you programmed in C C++. And know more than I do. VB uses the API too.
One of the switches in psshutdown is to force all running programs to close. Not allowing them to save information. So I would think conversely this allows all running programs to close correctly if you do not use that switch. That's my guess.
 

hemlock

Thread Starter
Joined
Aug 29, 2002
Messages
9
Much thanks for the info on Group Policy!

I feel a little shagrined, turns out that pstools has a pskill command that's roughly equivalent to Linux kill. And there is that bit in psshutdown about a forcing switch (implying otherwise orderly shutdown). I tryed pskill already on one of the programs I need to terminate & there didn't seem any problems. Between the two I think things should work out OK. Now I'll have to study up on Group Policy facilities, and trying to get APC software running in Linux. I'll post something when it all works out.
 
Joined
Aug 17, 2001
Messages
7,486
I am looking forward to it. Good luck. I hope you find a way to do what you need.

Mo
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top