3

I want my PC to create a folder with the day's date everyday. I cannot get it to work with Task Scheduler. Here's what I have:

  • Program/script: mkdir
  • Add arguments: TEST_%date:~10,4%-%date:~4,2%-%date:~7,2%
  • Start in: D:\File Backups\

Whenever I run this from command prompt, it works. I don't understand why it isn't working with Task Scheduler. It says The system cannot fine the file specified. (0x80070002).

When I run it from command prompt, here's what I say:

mkdir "D:\File Backups\TEST_%date:~10,4%-%date:~4,2%-%date:~7,2%"

I am using Windows 8.1.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • 2
    If D: is a network drive it won't work. Use UNC `\\server\share\folder\file.ext`. –  Dec 12 '16 at 17:41
  • 3
    Do you run the scheduled task under a certain user context or under system context? If you are trying to specify `mkdir` directly, you won't succeed as this is an internal command of `cmd` (command prompt), so try with `cmd /C mkdir ...` or `"%SystemRoot%\System32\cmd.exe" /C mkdir ...` instead. – aschipfl Dec 12 '16 at 17:55
  • The format of date string of environment variable `DATE` depends on Windows Region and Language settings defined for the __used user account__. This could mean that the date string is formatted different on running the `mkdir` as scheduled task using system account than when you with your user account run the same command. For a Windows Region and language independent solution see [How to get current datetime on Windows command line, in a suitable format for using in a filename?](http://stackoverflow.com/questions/203090/) – Mofi Dec 12 '16 at 18:07
  • I am trying to solve similar question. is this solved? – v09 Jul 12 '17 at 16:06
  • @aschipfl : I tried using "%SystemRoot%\System32\cmd.exe" /c mkdir "Z:\some_name_commercial\%CurrentDate%" with no success. P.S : Z:\ is the network drive (NAS mounted) – v09 Jul 12 '17 at 16:10

0 Answers0