I want to modify a shortcut to use a different CPU affinity, e.g.:

cmd /c "start /affinity 7 path\program"

It works fine, until path or program contains spaces.

Then, quotes surrounding path\program would be needed, nested inside the other quotes.

How can this be achieved?

link|improve this question

76% accept rate
feedback

1 Answer

You should try to use backslashes as escape character :

cmd /c "start /affinity 7 \"path\program\""

Note that backslashes are only special if they are in front of a quote or a backslash

Update :
Officially, the solution above should work, but in practice it seems it doesn't.

I tried without the backslashes and, although it sounds strange, it works for me (Win XP).

cmd /c "start /affinity 7 "path\program""

link|improve this answer
that results in > "\"path\program\"" could not be found... – Tobias Kienzler Aug 23 '10 at 13:58
You're right, sorry... Did you try without the backslashes ? I just tried it and it works for me (on XP) : cmd /c "start /affinity 7 "path\program"" – Julien N Aug 23 '10 at 14:26
it does not really work as intended. All consecutive parts of string are just concatenated, may them be quoted or no ("a b"c becomes a bc as one argument), and if you'll add a space to "path\program", you'll see how it fails. – whitequark Aug 23 '10 at 15:37
unfortunately that doesn't work either - for shortcuts. When I use Start->Run... I don't seem to need any quotes at all. Weird. I'm using WinSever2k3. Using a second shortcut to be executed via start ignores the affinity setting, so I guess I have to add program to my path. But thanks for trying, I'll check it on my Win XP at home, too. – Tobias Kienzler Aug 24 '10 at 7:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.