2

So I found this Stack Overflow question which relates to what I would like to do; however, I am having trouble with the directory having spaces within it. I tried looking at several other Stack Overflow questions, but either I misunderstood them, or none have really addressed my problem. I've seen stuff on passing arguments as arrays and using %1 or something to address the special characters, but nothing has worked yet.

I tried entering the following into cmd.exe:

schtasks /Create /SC DAILY /TN PythonTask /TR "python "C:\Users\me\stuff   with  spaces  \pythonprogram.py""

However, the quotes appear to not be taken in the correct order. I would like the command to be input as python "C:\Users\me\stuff with spaces \pythonprogram.py" to cmd.exe everyday.

How can I use quotes around quotes on the Windows command line?

ANSWER FROM BELOW:

Add a backslash \ before the argument which you are putting in quotes. I.e.:

do_some_command_in_windows_shell_with_this_given_string "run "something.exe""

is replaced with:

do_some_command_in_windows_shell_with_this_given_string "run \"something.exe""
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
chase
  • 3,592
  • 8
  • 37
  • 58

1 Answers1

5

Educated guess:

Escape the inner quotes with a backslash.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • Aha! I feel like an idiot now. Thank you very much. I just added one backslash before the 2nd argument like so: `schtasks /Create /SC DAILY /TN PythonTask /TR "python \"C:\Users\me\stuff with spaces \pythonprogram.py""` if anyone runs into the same problem and can understand my example. – chase Jun 20 '13 at 04:46