user2961293
user2961293

Reputation: 1

How to start Outlook from within a batch file on Windows XP

Good day,

I'm trying to find a way to open Outlook automatically from within a batch file called via the Task Scheduler, but can't seem to land on a method that works. The overall reason I'm doing this is that I'm trying to automate a backup of the Outlook pst file. Outlook needs to be closed to copy the pst file. I can kill Outlook okay and copy the pst file. I'd just like to be able to restart Outlook automatically when I'm done.

I've tried a number of variations using the runas command such as:

runas /savecred /user:computername\mark "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE"

and

runas /noprofile /savecred /user:peter-fe7f4dbcd\mark "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE"

These work fine from the command line, but when started via Task Scheduler, Outlook never starts. Windows Task Manager shows the process runas.exe as having been launched. It appears to be waiting for something like my user credentials, but there's no way to tell.

I've also tried using the start command to no avail as yet. Using the following syntax results in Outlook starting as a new process shown within Task Manager, but Outlook never appears on my desktop.

start /d "C:\Program Files\Microsoft Office\Office" OUTLOOK.EXE

Note too that this works fine if run from a command prompt. Also note that my Mark account is a member of both the Administrators and Users groups.

I'd appreciate any ideas you guys might have to get this to work.

Thanks a lot. Mark

Upvotes: 0

Views: 8818

Answers (1)

user2961293
user2961293

Reputation: 1

Thanks a million David! I actually didn't realize I could create a task using the Task Scheduler program. Doing as you suggested and providing my Windows password for the task works perfectly. I was adding the task via the command line:

at 3:00 /every:s d:\batfiles\Start_Outlook.bat

So as expected in Task Scheduler this was shown as been created by the System user. I'm still curious if anyone has a method that would work to start Outlook via a batch file that is run by the System user.

Many thanks.

Upvotes: 0

Related Questions