# Open up Outlook using a batch file.



## vane0326 (May 8, 2006)

Hi everyone,

I have this computer that is being shared by many users and sometimes they close out Outlook. I would like to run a scheduled task manager that execute the batch file and check if Outlook is close, if it is then open a Outlook session.

If it's already open then *do not* open another Outlook session.

Is that possible*?*


----------



## notnewcivilman (Jul 10, 2009)

OK, i wrote this program to do just what you are asking for... Follow the link provided: http://cid-2338298ad83e96d6.skydrive.live.com/browse.aspx/Public?uc=2&lc=1033

There are two files: Outlook Keepalive Application.exe and Outlook_Keepalive_Application_SOURCE_CODE.txt. Just click on the Outlook Keepalive Application.exe link then click on it once more and the download should start. The app is about 74K so not very big. To close the application you have to kill the process from task manager. You can not close it with the "X" button.

If you have any questions about how to use the program just ask...

Thanks,
Mike


----------



## TheOutcaste (Aug 8, 2007)

Do you use Fast User Switching on this PC?
If so, do you want it to start Outlook for the Current User if it is already running under a _different_ User Account?
This will start Outlook if it's *not* running for the Current User even if it _is_ running for another user:

```
@Echo Off
For /F "Tokens=1" %%I In ('tasklist /FI "IMAGENAME eq OUTLOOK.EXE" /FI "USERNAME eq %Username%"') Do If /I "%%I"=="OUTLOOK.EXE" Goto :EOF
Start Outlook.exe
```
This will only start Outlook for the Current User if it's _not_ running for *ANY* user:

```
@Echo Off
For /F "Tokens=1" %%I In ('tasklist /FI "IMAGENAME eq OUTLOOK.EXE"') Do If /I "%%I"=="OUTLOOK.EXE" Goto :EOF
Start Outlook.exe
```
HTH

Jerry


----------



## vane0326 (May 8, 2006)

TheOutcaste said:


> ]This will only start Outlook for the Current User if it's _not_ running for *ANY* user:
> 
> ```
> @Echo Off
> ...


Thank you Jerry I tested it out and it works great. Is there a link where there are examples of batch files?

Also, thank you for your program notnewcivilman. I'm going to use it for something else.


----------



## TheOutcaste (Aug 8, 2007)

Lots of good reference stuff out there. These are some I've used often. Rob van der Woude's site has lots of examples:
DOS and VB Scripting Links
An A-Z Index of the Windows XP command line
Command-line reference A-Z
Using batch parameters
Windows 95/98/ME Batch file Tutorial (Still a good basic reference for WinNT/2K/XP)
Batch File Functions for NT4/2000/XP/2003
Rob van der Woude's Scripting Pages
Microsoft Script Center
Beginners Guides: WindowsXP Command Prompt
Beginners Guides: Understanding and Creating Batch Files


----------

