00 Votes

Batch/CMD: Pass Parameters containing Spaces

Question by Guest | 2014-06-10 at 16:58

I would like to pass a file path to one of my applications via the command line (later I want to use a batch script for this).

Unfortunately, this is only working when the path does not contain any spaces or blanks.

What can I do to be able to pass a parameter even if it contains a space?

ReplyPositiveNegative
0Best Answer0 Votes

Usually, spaces are used to divide the single parameters from each other. For example, when passing 

prog.exe C:\Folder A\File.txt

to the program prog.exe, the application would receive two parameters. That is "C:\Folder" as the first parameter and "A\File.txt" as the second parameter.

prog.exe "C:\Folder A\File.txt"

You have to surround the parameters containing spaces with quotation marks. This makes them to be recognized as only one individual parameter.
2014-06-10 at 19:37

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.