Felix Waltl
Felix Waltl

Reputation: 129

scheduled tasks via cmd / quoting Problem

I've a problem with quotes when creating scheduled tasks over command line. I try to create a task which starts a batch script and passes some parameters to it. The command looks like following:

 SCHTASKS /CREATE /RU "MyUserName" /SC ONCE /ST 00:00 /TN "TestTask" /TR "D:\Thats\my\script.bat 'P:\aram\one' 'P:\aram\two\'" /IT /F 

Now, the task gets created but if I check it via

CHTASKS /query /TN "TestTask" /FO List /V

I get following info:

D:\Thats\my\script.bat "P:\aram\one" "P:\aram\two\'

instead of following info:

D:\Thats\my\script.bat "P:\aram\one" "P:\aram\two\"

The second info has a double high quote at the end and the first one not. May some one asks what kind of path that is which ends with a slash, but I do need it for a script.

My second question is why the task scheduler seems to change every single quotes into double quotes.

Upvotes: 0

Views: 260

Answers (1)

Magoo
Magoo

Reputation: 80073

[Untested]

I believe that the backslash before the single-quote is escaping that single-quote, as indicated by your results (actual ends single-quote, expected double)

So - I'd try doubling that backslash so that it is backslash that is escaped.

Upvotes: 1

Related Questions