views:

1116

answers:

2

I realize that this question is "answered" at the following thread: http://stackoverflow.com/questions/447774

However, I'm still having trouble understanding the answer and seeing exactly what the result would look like for my situation.

My schtasks command looks like this:

schtasks /create /tr "C:\Program Files\Java\jre6\bin\javaw.exe main.MoveFile input.txt" /sc WEEKLY /tn mytask

I want to specify the start in directory of "C:\My Library". Putting a "\" before the tr section fills in a start-in directory of "C:\Program Files\Java\jre6\bin".

I've messed around with it a lot, but I just can't seem to make it work.

I apologize if starting a new thread like this is against normal procedures, but I don't have a high enough reputation to put a comment on the other thread :).

Thanks, B.J.

A: 

Not sure what version of Windows you are on, but from reading the other question it looks like schtasks on Vista / Server 2008 does not provide a command option that would allow you to specify a "start-in" directory directly. The workarounds people provided were:

  1. Use the /v1 flag to create a XP / 2003 compatible task, in which case the "start-in" directory is automatically set. Not sure what it is set to but I suspect it may be the same directory as your task executable, which won't work for you.
  2. Create your task from an XML file (using the /XML option) which does allow you to specify a "start-in" directory. Sorry I don't know the syntax / structure for this XML file.
  3. Create your task using the Task Scheduler UI instead.
Amal Sirisena
A: 

I have found that if you use the 8.3 naming convention in the SCHTASKS command line for the path and file names the "Start In" field is polulated with the file path -

e.g. "C:\Progra~1\NBVCl~1\nbv_up~1.exe" will result in "C:\Progra~1\NBVCl~1" appearing in the "start In" area