PDA

View Full Version : How to Terminate a program


rjh01
10th August 2009, 07:21 PM
I automatically backup some files everyday. The problem is one of them is my Outlook file. I run Outlook all the time and the backup will not run properly when Outlook is running as both want the file to themselves.

So I want to be able to terminate Outlook at a certain time so that the backup will work. How do I do this?

I can manually restart Outlook afterwards. But I need a way for the computer to terminate it without me doing anything at the time.

I use Windows XP and Nero V9 to do the backup.

Mitchell314
10th August 2009, 07:31 PM
I haven't used windows in a while, but can't you schedule a batch file to taskkill an application? I can do it if I know the ID, but I don't know how to do it by name.

ETA: Taskkill: http://technet.microsoft.com/en-us/library/bb491009.aspx
ETA2: at (for scheduling stuff, but I've never tried it before): http://ss64.com/nt/at.html
ETA3: If you don't like at, there's the gui scheduler http://support.microsoft.com/kb/308569

xenxabar
10th August 2009, 09:05 PM
Why not just schedule your backups to run before or after your daily computer usage? That way you can simply close Outlook before that time. After all you are considering manually restarting Outlook as part of a solution.

GreNME
10th August 2009, 09:19 PM
Be aware that using taskkill to stop Outlook could result in a damaged pst file.

My suggestion is to look into AutoIt (http://www.autoitscript.com/autoit3/) for closing Outlook. It can simulate mouse clicks and as such you can make a quick, simple AutoIt script that can be compiled to an exe file and set through your task scheduler to run.

Ducky
11th August 2009, 12:50 AM
crontab -e

Add:

* 11 * * * ps -ef | grep Outlook | xargs kill -9
* 12 * * * /home/user/bin/backups.sh 2&1 > /home/user/log/backuplog.txt

Where backups.sh is your rsync to offsite/other disk script to backup data.

Cron ftw.


WHAT? WELL SOMEONE HAD TO MAKE THE *NIX JOKE! IT'S LIKE INTERNET LAW OR SOMETHING!

jsiv
11th August 2009, 01:28 AM
http://i25.tinypic.com/2jfrcj.jpg


closeoutlook.vbs:

on error resume next
set ol = getobject(, "outlook.application")

if err.number = 0 then
for each inspector in ol.inspectors
inspector.close(olsave)
next

ol.quit()
end if

rjh01
11th August 2009, 02:04 AM
Thanks for all the ideas. I have downloaded AutoIt.

Tried to run jsiv's macro but got a compile error on ol.quit() it was expecting =. I am using the 2000 version of office.

I might also try to run the backups when I log on and before Outlook starts.

MortFurd
11th August 2009, 09:14 AM
crontab -e

Add:

* 11 * * * ps -ef | grep Outlook | xargs kill -9
* 12 * * * /home/user/bin/backups.sh 2&1 > /home/user/log/backuplog.txt

Where backups.sh is your rsync to offsite/other disk script to backup data.

Cron ftw.


WHAT? WELL SOMEONE HAD TO MAKE THE *NIX JOKE! IT'S LIKE INTERNET LAW OR SOMETHING!
What? Doesn't everybody have the MS/Interix services for unix installed?

~enigma~
11th August 2009, 09:50 AM
Write a routine that calls Kristianna Loken and your termination trouble will be solved :)

jsiv
11th August 2009, 11:02 AM
Thanks for all the ideas. I have downloaded AutoIt.

Tried to run jsiv's macro but got a compile error on ol.quit() it was expecting =. I am using the 2000 version of office.

I might also try to run the backups when I log on and before Outlook starts.
I'm running 2007, but I'm pretty sure it should work on 2000 as well. Exactly how are you running it? Just double-clicking it/running it with cscript closeoutlook.vbs?

GreNME
11th August 2009, 01:58 PM
What? Doesn't everybody have the MS/Interix services for unix installed?

I do. I wouldn't recommend what Ducky listed for the exact same reason I cautioned against Taskkill (which essentially does the same as kill).