• Close Outlook from a .bat file (Windows XP/SP2 Outlook2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Outlook and email programs » Close Outlook from a .bat file (Windows XP/SP2 Outlook2003)

    Author
    Topic
    #429608

    Is there any way to close down Outlook 2003 from within a batch (.BAT) file? I run a batch file every night (using the standard Windows XP Scheduler to run unattended) to clean up stuff and back up all my data files (BackupPlus from Avantrix). If I fail to manually shut down Outlook before this run, the backup program notes that the .pst files are in use and skips them. This is not good. I checked the Outlook command line switches but did not find anything relevant. I tried to Copy and XCopy the files to temporary files but they’re locked out of those commands also. Any ideas how to determine if Outlook is running, and, if it is, to shut it down?

    Thanks, John Littell

    Viewing 1 reply thread
    Author
    Replies
    • #1001439

      See post 457,317 – there are various options in that thread.
      HTH

      • #1001698

        Thank you for the replies, That referenced thread was an interesting conversation. I jumped into the middle and used the solution that had a “cscript.exe //nologo StopOL.vbs” statement invoking a script that defined an instance of Outook and then sent a Quit to it. It appeared to work as the copy that was open on the screen disappeared.

        But then a new problem; actually it seems that I’ve had it for some time but did not associate it with Outlook. After deactivating Outlook – either programatically or by the normal manual method – the task remains active permanently in the Task Manager list (Ctrl-Alt-Del). If I subsequently open a second copy and then close it, a second task is shown permanently open in the list. And a third, etc. The only way to clear them out seems to be to reboot. But then, during the task closing process of power down, for each copy of the Outlook task I receive an error window titled “MCI Command Handling Window” saying “This program is not responding” with instructions to click on “End now.” Each instance of this error window clears out one copy of Outlook from the task list.

        As I said, I’ve had this problem for some time but did not know it was Outlook oriented. Please, how do I get rid of it?

        John

        • #1001704

          If you search for “recycle” on this board you hopefully will find some discussion on how to limit Outlook to starting a single session (in which you might have multiple windows but you should not have multiple entries in your processes list).

          Regarding StopOL.vbs, I think I wrote that a long time ago. grin Now that we use Exchange rather than a POP server, there is another method (Logoff ?) that I think might be required or at least helpful to add before Quit, if it wasn’t already in there. Not sure whether that applies to your situation.

          Also, there is some chance that if you clicked a mailto link in IE, your mail program might remain active until IE is closed. I haven’t checked on that lately, but I think it happened in earlier versions of IE/Outlook.

        • #1001723

          The writeup for PsKill indicates that it terminates all copies of . After Jefferson’s program has run, perhaps see if PsKill does what you want?

          John

          • #1001736

            Jscher2000,
            Yes, you were part of a conversation back in March for which the Recycle switch was the solution, but the code that I copied was submitted by rory. That problem then was starting a second window of Outlook while a first copy of Outlook was already open. My problem now is that the first instance of Outlook has been manually closed (though it still shows up in the task list), and then a second instance of Outlook is started causing two processes to show in the task list. Specifically, this happens:

            1. Boot up Windows, Press Ctrl-Alt-Del to open the Task Manager window.
            2. Activate Outlook. (Click on actual .exe file; no special shortcuts involved.) Outlook.exe shows on screen and in the Task Manager window.
            3. Manually close Outlook. (The absolute normal way.) Outlook is off the screen but still shows as an active process in the Task Manager window.
            4. Activate Outlook. Outlook is on the screen and two lines of Outlook.exe show in the Task Manager window.
            5. Manually close Outlook. Outlook is off the screen but the two lines of Outlook.exe still show in the Task Manager window.
            6. Shut down Windows.
            6a. Window titled “MCI Command Handling Window” saying “program not responding”, I click End now. One Outlook is gone.
            6b. Window titled “MCI Command Handling Window” saying “program not responding”, I click End now. Other Outlook is gone.
            Now both Outlook processes are gone from the Task Manager window and Windows shuts down. During this experiment nothing else was done: IE was not activated nor was the default Filefox.

            I admit that the above digresses from my original problem; I consider that one solved. (See next message). I would still appreciate your thoughts on the above scenario as this is what is happening when using Outlook in a perfectly ordinary way.

            Thanks, John

          • #1001738

            JohnGray,
            PsKill does do what it advertisements. At the time I first used it, seven outlook.exe processes were shown in the Task Manager list as active (although all seven had been manually exited from the screen). “PsKill Outlook.exe” immediately wiped out all seven processes.

            Any other side issues to adding this to my cleanup batch file? Like will it flush any unwritten buffers before killing the application?

            John

            • #1001748

              > will it flush any unwritten buffers before killing the application?

              Seem very doubtful.

              The strange window title (MCI something or other) suggests interaction with another program or process. Googling briefly doesn’t give any clear answers, but perhaps some further investigation is in order before going to the brute force shutdown.

            • #1001778

              There is ‘something’ wrong with this because you should only get one copy of Outlook.exe in the Processes tab of Task Manager per Outlook window you start and have currently available. If you close an Outlook window, then the corresponding Outlook.exe process should be terminated. (You know all this!).

              My concern with PsKill being used for removing Outlook processes is only that there might be corruption to mailboxes or PST files if you terminate a process at the wrong time. On the other hand, at home, it occasionally happens that Outlook Express ‘hangs’ and I try to start another instance, which of course doesn’t work. Then I manually do End Process on the msimn.exe process(es), and simply get a “You didn’t shut Outlook Express cleanly”-type message when I next start it up. I’ve never had any corruption of messages, to my knowledge. I can vaguely remember getting a “multiple copies of Outlook” problem on NT4 some years ago, but I can’t remember what the problem was…

              I suppose it is a silly question to ask if you have applied all updates to XP subsequent to SP2 (clutching at straws!)?

              John

            • #1001812

              JohnGray,
              Your suppositions are correct. I know that only one Outlook process is supposed to appear in the Task Manager list. That’s what is driving me crazy. And yes, SP2 and ALL updates to Windows and Office have been applied.

              Also yes, I agree that using something as violent and abrupt as FsKill is asking for corrupt .pst files. What I was thinking was to combine two of the techniques discussed earlier as follows:

              1. Invoke the script that Rory contributed back in the March thread to close Outlook politely. Here is the script:
              Dim oAppOL
              set oAppOL = CreateObject(“Outlook.Application”)
              oAppOL.Quit
              set oAppOL = Nothing

              2. Then run FsKill to clear out the Task Manager process list. I realize that this is only a rough work-around and does not solve the cause of the problem. So I’m still looking toe ideas.

              Thank you, John

        • #1001779

          Do you have any Outlook add-ins installed?

          • #1001815

            rory,
            I was not even aware that Outlook had add-ins. So, looking into help and finding out that Outlook add-ins have an ECF extension, I searched and found that I have the following files: (Descriptions are copied out of Outlook Help)

            DLGSETP.ECF Delegate Access: Adds the Delegates tab to the Options dialog box (Tools menu)
            DUMPSTER.ECF Deleted Item Recovery: Adds capability to recover previously deleted items
            FAXEXT.ECF Microsoft Fax extensions: Enables extensions created for Microsoft Fax
            MSSPC.ECF Schedule+: Provides Microsoft Schedule+ compatibility
            OUTEX.ECF Remote Exchange Extensions: Adds Remote Mail settings to the Mail icon (Control Panel)
            OUTEX2.ECF
            PMAILEXT.ECF Windows CE Support: Adds Windows CE Inbox transfer support
            SCRPTXTN.ECF (Outlook Help lists Scrpxtn.ecf – Scripting Support…)
            fxsext.ecf (This is the only one in the Windows directory; all others in Program Files)

            Help says that they are installed automatically. I have no idea.

            John

            • #1001824

              Under Tools-Options on the Other tab, there is a button called COM Add-ins. Select that and uncheck any add-ins that are listed. Then close Outlook and see if any instances remain in the task list.

            • #1001835

              rory,
              I thought we had a winner. I saw that one add-in line was checked – AttachmentOptions – and unchecked it. Then I exited Outlook, looked at the Task Manager list, and it was gone.

              Then to make sure, I rebooted and performed the six steps listed above. Open and then close Outlook two times and, darn it, it’s still in the task list two times. (I did go back to double-check the Com Add-ins section and verified that no add-ins were checked. Just two items are shown: AttachmentOptions and MailBuddy Outlook Addin, but their boxes are not checked.)

              Still hoping, John

            • #1001841

              I will have to do some more research!
              Incidentally, does your Outlook start in ‘Outlook today’ or another folder?

            • #1001868

              rory,
              I do not have an ‘Outlook today’ folder.

              “Outlook.exe” is listed by the my file search program (Agent Ransack) four times as follows
              1. C:Documents and SettingsJohn LittellLocal SettingsApplication DataApplicationHistoryOUTLOOK.EXEc1b4c359.ini
              2. C:Program FilesMicrosoft OfficeOFFICE11OUTLOOK.EXE (I assume this is the one.)
              3. C:WINDOWSInstaller$PatchCache$Managed9040111900063D11C8EF10054038389C11.0.7969OUTLOOK.EXE
              4. C:WINDOWSPrefetchOUTLOOK.EXE-0CC1C5E5.pf

              The shortcut icon in the quick launch tray that was put there when Dell pre-installed Office 2003 Pro and which I use to launch Outlook contains the following
              Its Location: field contains “C:Documents and SettingsJohn LittellApplication DataMicrosoftInternet ExplorerQuick Launch”
              Its Target: field contains “Microsoft Office Professional Edition 2003” but those contents are grayed out.

              That filespec folder (“…Quick Launch”) contains two Shortcuts with Office Outlook in their names:

              “Launch Microsoft Office Outlook”
              Its Location: field contains “C:Documents and SettingsJohn LittellApplication DataMicrosoftInternet ExplorerQuick Launch”
              Its Target field contains “C:Program FilesMicrosoft OfficeOFFICE11OUTLOOK.EXE” /recycle

              “Microsoft Office Outlook 2003”
              Its Location: field contains “C:Documents and SettingsJohn LittellApplication DataMicrosoftInternet ExplorerQuick Launch”
              Its Target: field contains “Microsoft Office Professional Edition 2003” but those contents are grayed out.

              I assume by following the pointers that the first of the two shortcuts above is used, although the shortcut names don’t bear that out.

              There, that’s everything you probably never wanted to know about my Office setup. I really hope this lets you find what you’re looking for..

              John Littell

            • #1001871

              Do you use WinFax Pro or an ActiveSync type program for a PDA? If so, does it help if you disable them temporarily?

            • #1001877

              rory,
              A definate no to both. My Fax machine is offline and I have no PDA or portable type devices that would need synchronizing. If it could possibly be relevant, I do use the ZoneAlarm Security Suite.

              John

            • #1001878

              Do you have the MailSafe option turned on in ZA? If so, try disabling it temporarily.
              One other thing: is this a clean new installation of Office 2003 or an upgrade? Specifically, are you using a pst file created in a previous version of Outlook?

              Oh, and do you have Instant Messaging enabled in Outlook?

            • #1001881

              1. I turned both inbound and outbound MailSafe protection in ZA, rebooted, and did the above six steps. After I closed everything down still two Outlook.exe lines showed in the Task Manager list. I then shut down ZA completely. Did the same and the same thing happened. Reset ZA back to its norm.

              2. Office 2003 was installed by Dell as a clean copy (new,empty .pst file) when I bought the PC. I have not re-installed anything. I did use the Files and Settings Transfer Wizard that came with Windows ME to transfer all office settings. That, however, was two years ago and this MCI Command Handling Window to delete each Outlook process in the task list only started some months ago.

              3. IM. The following is from FireFox Help when I searched on Instant Message. The section is how to enable IM.
              Quote… Enable Instant Messaging
              On the Tools menu, click Options, and then click the Other tab.
              Under Person Names, select the Enable Person Names Smart Tag check box, and then select the Display Messenger Status in the From Field check box.
              Unquote… Their terminology seems odd, but in those terms…

              The Enable Person Names Smart Tag check box is checked.
              The Display Messenger Status in the From Field check box is Not checked.

              John

            • #1001888

              One more thing to eliminate. You have probably noted that my default browser is Firefox. I switched the default back to IE 6 and ran steps 1 – 6 in that environment. No change. Now how do I switch it back again? (Kidding. I’ve written it down somewhere.)

              John

            • #1001906

              Do you use a third-party junk mail/spam filter program? (e.g. the junk mail filter in ZA) Again, if so, try turning that off.
              I note you say that this started happening a few months ago – did anything change at that time that you know of? Do you have the exact MCI error message that appears?

            • #1001924

              ZoneAlarm Security Suite spam blocking: The spam blocking column in the Settings tab is set to off. Remember, however, several entries in this conversion back, I ran the 1-6 test with ZA turned completely off.

              Other Virus/Spam/Junk Mail/etc. programs: Once a week I run Ad-Aware SE Personal, Registry First Aid, Spy Sweeper (Webroot), CWShreadder, Spybot Search and Disproy, and once some months ago I ran RootKitRevealer but I’m not comfortable with its reviews. Of these Spy Sweeper runs in the background. So even though its help system made no mention of spam, I shut it down and ran the 1-6 test. The results were unchanged.

              I tried to capture the MCI error screen image for you but Windows was shutting down and would not let me. So, the title says “End program – MCI command handling window”; an icon with the letters MCI appears at the top left of the screen body, and then appear the following messages “This program is not responding.” “To return to Windows and check the status of the program, click Cancel.” “If you choose to end the program immediately, you will loose any unsaved data. To end the program now, click End Now.” Then are the two buttons “End Now” and “Cancel”

              Of course the “has anything changed” question is the first thing to ask. Unfortunately being on the web and downloading stuff several hours a day makes this impossible to answer. Various new versions of the programs mentioned above were implemented, but other than the Spy Sweeper possibility they don’t seem to apply.

              I could say I hope this helps but I can’t see how is could. Please keep trying.

              John

            • #1001930

              Well, I’ve done quite a lot of searching but all I’ve really learned is that:
              1. You are not alone with this issue, but solutions seem to be in short supply!
              2. The MCI error appears to relate to hidden application windows which are busy trying to do something – presumably these are the hidden instances of OL.
              3. The general consensus seems to be that another program (add-in or otherwise) is trying to use Outlook and when you close the GUI, the other program keeps the actual application open.
              As a matter of interest, how often do you have Outlook set to check for new mail? I’m wondering if perhaps that might be keeping the process alive.

            • #1001931

              Short answer: Send/Receive is set for every five minutes. I will try variations.

              Long answer: I agree with all of your conclusions. I also have Googled another instance of someone in another forum asking the meaning of the “MCI” error window. From what I could tell, no answers were forthcoming.

              In the mean time until the next version of Windows/Office, does anyone see any problems with my shutting down Outlook in a batch file (remember? That was the original question.) by these two steps which I’m reshowing from above?

              1. Invoke the script that Rory contributed back in the March thread to close Outlook politely. My assumption is that this would flush any buffers that are still active. Here is the script:

              Dim oAppOL
              set oAppOL = CreateObject(“Outlook.Application”)
              oAppOL.Quit
              set oAppOL = Nothing

              2. Then run FsKill to clear out the Task Manager process list.

              The hope is that this would let me accomplish my overall objective of a) Backing up my data including the .PST files, and Powering down (I already know how to do this) all from an unattended scheduled batch file.

              Thank you all for your contributions. It is a kick to know that this kind of support is available. (It’s also a kick to try to figure where in the world you’re located.)

              John Littell
              From the Oregon Coast

            • #1001959

              In view of the issues you are having, you may wish to change the second line to:
              set oAppOL = GetObject(,"Outlook.Application")
              and see if that manages to pick up one of the hidden processes. (If not, just change it back)
              As far as the locations go, the profiles are usually a giveaway… grin

    • #1001441

      What you actually need is a clean command-line method of terminating Outlook! (I didn’t find one on a quick Google…).

      If you are feeling courageous or cavalier (or both!) you can use Sysinternal’s PsKill in the simple form PSKILL OUTLOOK . If OUTLOOK is not running, then it doesn’t kill it … [doh!].

      But be aware of the possiblility of corruption of PST files, etc… Your Corruption May Vary…

      John

      PS Posted before I saw Rory’s post above…!

    Viewing 1 reply thread
    Reply To: Reply #1001924 in Close Outlook from a .bat file (Windows XP/SP2 Outlook2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel