0

I'll try to keep this short, without all the details of this batch file procedure.

OS: Windows XP Action: Scheduled Task (background, I can't find a way to run it in the foreground) Problem: files not created on mapped drive. When the batch file is ran directly, it works.

It does the following (or at least tries to):

  • clean a directory: works
  • create executables based on a substituted location We use the following to map a local folder to the K: drive:

subst K: /D subst K: D:\Development\SVN

The executables are built from source code that is located on (for example) K:\Sources to K:\Executables.

This fails, for a reason I did not yet discover. As mentioned above, if the batch file is ran directly it doesn't fail. If I substitute K:\ by C:\Development\SVN the issues seem to be resolved but still, this doesn't solve the fact that I can't run it when using K:.

I hope anyone here has an idea, I tried Googling for a long time + scanning SO but to no avail.

Thanks in advance!

Starceaker
  • 631
  • 2
  • 5
  • 14

1 Answers1

2

substed drives are local to session, and your scheduled task is run in another session then your login session.

It seems to be possible to schedule task for user login session with schtasks.exe command line, but then the task runs only if the user is logged in. It might not be what you want, so using a full non-substed path might be the best solution after all.

Community
  • 1
  • 1
Anton Kovalenko
  • 20,999
  • 2
  • 37
  • 69
  • I figured the local session might be an issue, what I tried to counter this is to add the subst in the beginning of my batch file (that is then ran in another session) but this also didn't solve the issue. It's clear that using a full non-substed path might be a solution. On the other hand I'd like to get it working with the substed path so: 1. I'll try the schtasks.exe suggestion 2. Do you think adding the subst in the batch should work in theory, ie. that I did something wrong when I tried it the first time? – Starceaker Jan 27 '13 at 12:32
  • I'd expect adding the subst in the batch to work, too (that's what I would try). I don't know, maybe you just aren't allowed to subst in that global session. It would be interesting to redirect stdout and stderr (`subst ... 2> errors.txt >output.txt`), maybe it prints a useful error message when it fails. – Anton Kovalenko Jan 27 '13 at 12:38
  • Ok thanks, I'll experiment with this in the near future. I have to work on something else first for now. I'll up your reply for now, as it's definitely helpful. – Starceaker Jan 28 '13 at 13:23