Win2003 Scheduled task command line expansion bug?

I have a nighty NT Backup task (on Windows Werver 2003) like this

ntbackup.exe backup  /n "Nightly Backup %DATE%"  /d "Set created %DATE% at %TIME%"

(irrelavant stuff removed)

The %DATE% and %TIME% do expand, but they don't expand correctly, I get
Media name: "Nightly Backup 4/20/2006ATE%"
and
Backup description: "Set created 4/20/2006ATE% at 3:30 AMIME%"

Thus the "ATE%" portion of "%DATE%" and the "IME%" portion of "%TIME%" don't get replaced.

Am I doing something wrong or is this a bug?
LVL 16
JohnBPriceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WelkinMazeCommented:
Hi,

You can try this one:
echo "Nightly Backup %DATE%" "Set created %DATE% at %TIME%"

If it is not correctly printed then you are doing everything right and it is some bug.
0
JohnBPriceAuthor Commented:
It does correctly replace from command prompt (same machine, same user account the scheduled task runs under).  Furthermore, it replaces differently, %DATE% includes the day abbreviation, and time is hh:mm:ss.ss.  Makes me suspect there might be some environment variable that doesn't set for scheduler?
0
WelkinMazeCommented:
Hm, really strange.
Maybe you can try to set "Nightly Backup %DATE%"  and "Set created %DATE% at %TIME%" preliminary to some other variables and to use these variables when executing the command.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

boris711Commented:
I'm not trying to be a wiseguy, but what happens if you shorten the variable references to %D and %T? While what you're getting isn't expected behavior, it would seem that the variables are still being interpretted correctly adding the unnecessary reference parts back into the text line.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WelkinMazeCommented:
boris711, I've thought about the same but %D and %T do not work at the command line in normal circumstances. Maybe there are some specific variables for the backup application. Anyway, it will be fine if this works. :)
0
boris711Commented:
Another thought. You can check the currently configured system variables by typing "set" at a command-line, it is possible that "D" and "T" have been configured as variables representing the Date and Time, respectively. Though that doesn't explain why the trailing "%" sign is still left in the string.
0
JohnBPriceAuthor Commented:
Boris, expansion requires an opening and closing "%", e.g. %Date%  will not expand the %D portion.  %Date% and %Time% are built-in variables, they are not defined.
0
boris711Commented:
I understand that %DATE% and %TIME% are built-in system environment variables. Was wondering if "D" and "T" had possibly been defined as variables equivalent to the above respective values.

My assumption is that you're using Task Scheduler. How are you calling "ntbackup" with a script, batch file or passed as a command-line?  

0
JohnBPriceAuthor Commented:
OK, I give.  If I schedule this task  >C:\WINDOWS\system32\cmd.exe /C "echo %DATE% t: %TIME%>C:\test.txt"
the results are  Thu 04/20/2006 t: 10:36:00.05", i.e. it works fine

If I run this >ntbackup backup "C:\test.txt" /F "C:\Test.bkp" /D "bk %DATE%"
the result is >Backup description: "bk Thu 04/20/2006", it also works fine,

but if I SCHEDULE the same >ntbackup backup "C:\test.txt" /F "C:\Test.bkp" /D "bk %DATE%",
the result is >Backup description: "bk 4/20/2006ATE%"
0
JohnBPriceAuthor Commented:
Boris, it is possible that NTBackup is doing the expansion instead of the shell, so maybe %D has some merit, testing now.

I am indeed using task scheduler, and I use the "ntbackup blah blah" as the "Run:".  It just occurred that I might be able to do cmd.exe /C "ntbackup .....", though I might get fouled with embedded quotes.  I'll try that too.
0
JohnBPriceAuthor Commented:
Bingo Boris!  You are da'man.  It seems that NTBackup simply expands %D, I scheduled:

ntbackup backup "C:\test.txt" /J "jb %DATE% " /F "C:\Test.bkp" /D "bk %D"

and got Backup description: "bk 4/20/2006"

Note that the job name didn't expand at all, the job was still "JB %DATE%"

go figure.
0
boris711Commented:
Have you tried encapsulating your command-line in a batch file and then calling the batch file from Task Scheduler?

Or VBScript is another option.

It is possible there is a bug in passing the switches thru Task Scheduler.
0
JohnBPriceAuthor Commented:
I tried the cmd.exe trick with

C:\WINDOWS\system32\cmd.exe /C "ntbackup backup ""C:\test.txt"" /J ""jb %DATE% "" /F ""C:\Test.bkp"" /D ""bk %DATE%"""

but got "Expecting more command line parameters." in the backup log.  I don't know how to escape quotes in shell commands.


>>Have you tried encapsulating your command-line in a batch file and then calling the batch file from Task Scheduler?
That would be a good third option too.  

Thanks for your help.
0
boris711Commented:
You're welcome and Good Luck!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Operating Systems

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.