Home All Lessons How to close Outlook via script

How to close Outlook via script


In many organizations, corporate postage monsters like Outlook are used. And, of course, you can get the task of a centralized backup of its pst files. You can use some kind of Outlook PST centralized backup program or simply self-written scripts that copy PST data to the storage. However, there is one caveat: there may be problems with the PST files of those users who do not close Outlook at the end of the working day after completion of work. If such a situation is not provided to your backup program / scripts, then the pst file will not be copied, or it may happen that it is damaged. But even if a variant of this situation is provided, it is not a fact that there will not be a rough closing method that can damage the pst file. I provide the script code that correctly closes Outlook:

On Error Resume Next
Set Outlook = GetObject (, “Outlook.Application”)
If Err = 0 Then
Outlook.Quit ()
End if

close outlook via script

Paste this code into the script file, for example, “close_outlook.vbs” and place this script in the launch scheduler a few minutes earlier than the PST file will be backed up.


Related post :  What process is using TCP port in Windows