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!

Need to close Outlook from VBScript

Status
Not open for further replies.

dgschnei

Technical User
Nov 26, 2002
14
US
I have a batch driven vbscript for daily and weekly (zipped) backups.
I want to backup my mail.
I need to close Outlook and save before zipping the Outlook mail files.

I can close Outlook using vbscript or batch file... whatever is easier.

How can I close Outlook?

I came up with this script but I am trying no to use sendkeys, because I am not sure if Outlook will be activated (visible) and sendkeys may be sent to another running application.

set ws = CreateObject("WScript.shell")

ws.Run "Outlook"
WScript.sleep 300
ws.AppActivate "Inbox - Microsoft Outlook"
WScript.sleep 300
ws.sendkeys "%f+L" ' alt-f

set ws = Nothing

Any idea?
Any help is welcomed, thanks in advance.

Regards

Dominique G. Schneider
 
Hello dqschnei,

It is this for the local.
Code:
set svc=getobject("winmgmts:root\cimv2")
squery="select * from win32_process where name='outlook.exe'"
for each oproc in svc.execquery(squery)
	oproc.terminate
next
set svc=nothing
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top