Author Topic: Close / Reopen Outlook  (Read 1037 times)

MW4

  • Full Member
  • ***
  • Posts: 143
Close / Reopen Outlook
« on: February 25, 2016, 04:51:54 pm »
What is the way to close outlook 2007 from a script?

Winclose("outlook") doesn't work

MW4

  • Full Member
  • ***
  • Posts: 143
Re: Close / Reopen Outlook
« Reply #1 on: February 25, 2016, 05:26:03 pm »
Nevermind..forgot the tilda

If WinExist("~Microsoft Outlook") Then WinClose("~Microsoft Outlook")

td

  • Tech Support
  • *****
  • Posts: 2223
    • WinBatch
Re: Close outlook 2007
« Reply #2 on: February 26, 2016, 02:06:58 pm »
This is an excellent example of my favorite kind of topic on this forum .  8)
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


MW4

  • Full Member
  • ***
  • Posts: 143
Re: Close / Reopen Outlook
« Reply #3 on: March 03, 2016, 10:08:31 am »
LOL ...  that was good

MW4

  • Full Member
  • ***
  • Posts: 143
Re: Close / Reopen Outlook
« Reply #4 on: October 03, 2017, 10:07:22 am »
Is there a better alternative way to close outlook and then re-open it?
I have started having issues with the above script in that outlook doesn't close and appears to be waiting for some input or no closing because it's in the middle of a send receive, etc.

MW4

  • Full Member
  • ***
  • Posts: 143
Re: Close / Reopen Outlook
« Reply #5 on: October 03, 2017, 10:13:23 am »
Here I go again...I came across this code below and it works PERFECTLY as a .bat file, how would I get this into WBT, as I want to make it more secure in an .exe?

@echo off
For /F "Tokens=1" %%I In ('tasklist /FI "IMAGENAME eq OUTLOOK.EXE"') Do If /I "%%I"=="OUTLOOK.EXE" taskkill /f /im outlook.exe
Start Outlook.exe

td

  • Tech Support
  • *****
  • Posts: 2223
    • WinBatch
Re: Close / Reopen Outlook
« Reply #6 on: October 03, 2017, 01:40:03 pm »
Have you tried "TerminateApp".  For example, on Windows 10 you can kill the "Mail" app with the following:

Code: Winbatch
TerminateApp("HxOutlook", 3, 0)

"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates