Sign in to follow this  
Followers 0
ROcHE

Script to shutdown MS Outlook correctly

6 posts in this topic

Some computers on a small LAN are using MS Outlook as their mail application. The .PST file is stored locally and I would like to make overnight backups of it. Outlook has to be closed for the backup to complete succesfully.

I need a script that will shutdown outlook properly. I can not simply use winclose or even taskkill.exe because the PST file has to be saved by outlook on every shutdown to make sure it is not corrupted.

Ideally, I need a script that will select Outlook in the taskbar, press file and then exit. Then a couple hours later, will restart the application with the same script, having a pause in between.

Is that possible with AutoIT?

Share this post


Link to post
Share on other sites



maybe:

Opt("WinTitleMatchMode",2)
WinActivate("Microsoft Outlook")
WinWaitActive("Microsoft Outlook")
Send("!f")
Sleep ( 50 )
Send("x")

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

maybe:

Opt("WinTitleMatchMode",2)
WinActivate("Microsoft Outlook")
WinWaitActive("Microsoft Outlook")
Send("!f")
Sleep ( 50 )
Send("x")
Perfect! Thank you very much!

Share this post


Link to post
Share on other sites

WinClose actually works fine. However, if the user has any unsaved messages he is writing, those will need to be saved to drafts or discarded because a dialog box pops up.

I tried the following against a base install of Outlook 2003 where I work:

Opt("WinTitleMatchMode", 2)
WinClose("- Microsoft Outlook")

While WinExists("- Microsoft Outlook")
    While WinExists("Microsoft Office Word","Do you want to save the changes")
        ControlClick("Microsoft Office Word","Do you want to save the changes", "&Yes")
    WEnd
WEnd

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

WinClose actually works fine. However, if the user has any unsaved messages he is writing, those will need to be saved to drafts or discarded because a dialog box pops up.

I tried the following against a base install of Outlook 2003 where I work:

Opt("WinTitleMatchMode", 2)
WinClose("- Microsoft Outlook")

While WinExists("- Microsoft Outlook")
    While WinExists("Microsoft Office Word","Do you want to save the changes")
        ControlClick("Microsoft Office Word","Do you want to save the changes", "&Yes")
    WEnd
WEnd
That's a nice addition! Thanks!

Share this post


Link to post
Share on other sites

Or with COM:

$oOutlook = ObjCreate("Outlook.Application")
$oOutlook.Quit

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0