- 1 year ago
How to properly pass parameters to START?
Comment
1 / 1
To properly pass parameters to the START
command in Windows, you need to consider the following guidelines:
Quoting Parameters:
- If a parameter contains spaces or special characters, enclose it in double quotes (
"
). - Example:
START "Title" "C:\Path\to\Program.exe" "Parameter 1" "Parameter 2"
- If a parameter contains spaces or special characters, enclose it in double quotes (
Quoting Program Path:
- If the program path contains spaces or special characters, enclose it in double quotes (
"
). - Example:
START "Title" "C:\Program Files\Program.exe" "Parameter"
- If the program path contains spaces or special characters, enclose it in double quotes (
Multiple Parameters:
- Separate multiple parameters with spaces.
- Example:
START "Title" "Program.exe" Parameter1 Parameter2
Escaping Quotes:
- If a parameter or program path includes double quotes, escape them with a backslash (
\
). - Example:
START "Title" "Program.exe" "Parameter with \"quotes\""
- If a parameter or program path includes double quotes, escape them with a backslash (
Here's an example that demonstrates the usage of the START
command with parameters:
batch@echo off
REM Start a program with parameters
START "My Program" "C:\Program Files\Program.exe" "Parameter1" "Parameter2"
REM Start a program with a program path that contains spaces
START "My Program" "C:\Program Files\My Program\Program.exe" "Parameter"
REM Start a program with a parameter that contains spaces
START "My Program" "Program.exe" "Parameter with spaces"
REM Start a program with a parameter that includes double quotes
START "My Program" "Program.exe" "Parameter with \"quotes\""
In the above example, we use the START
command to launch a program with different parameters. The program path and parameters are properly quoted where necessary to ensure correct parsing by the START
command.
Remember to adjust the program path, parameters, and title according to your specific use case.
By following these guidelines, you can pass parameters to the START
command in Windows batch scripts effectively.