Unable to use %systemroot% when scheduling a task

Nov 16, 2009 at 3:57 PM

Hi, I'm wondering if perhaps anyone has an example of scheduling a task using %system% or %systemroot% in the command syntax. I'm trying to dynamically schedule an NTBackup command remotely using task scheduler. For whatever reason, when I schedule a task where the Command path is @"C:\Windows\System32\NTBackup.exe", the task is scheduled and runs just fine.

However, when I use @"%systemroot%\System32\NTBackup.exe" as my command, I get a "Could not start" error message in my task scheduler. The error message reported in the SchedLgU.txt is "System cannot find the file specified".

Incidentally, when I run the command containing %systemroot% directly from the command line, it runs fine. Am I missing something?

Thanks in advance!

 

Brian

Coordinator
Nov 16, 2009 at 5:42 PM

I'm guessing the Microsoft team decided not to support environment variables in their actions. Unfortunately, after a few minutes of research, I could not find a remotable equivalent for ExpandEnvironmentStrings that would allow me to resolve environment variables from a remote system. I know you can usually find the path to the system directory in "HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRoot" so you could grab the value from a remote connection to that machine's registry and then build your path. Let me know if you find a nice way to do it and I'll consider it for addition to the library.