In order for a path that contains spaces to be recognized as a single path (argument), it must be quoted.
In order for an executable to execute in the current console window, synchronously, with its streams connected to the calling shell, it must be invoked directly, not via start
.
Direct invocation from cmd.exe
(only "..."
quoting supported):
"C:\Users\Bob Builder\Desktop\New Folder\test.exe"
From PowerShell:
& 'C:\Users\Bob Builder\Desktop\New Folder\test.exe'
Note:
PowerShell also supports '...'
strings (single-quoted), which are verbatim strings that are preferable to "..."
(double-quoted) ones if you do not require expansion of variables (string interpolation) - see the conceptual about_Quoting_Rules help topic.
For syntactic reasons, PowerShell requires the use of &
, the call operator to invoke commands that are quoted and/or contain variable references - see this answer for details.
By contrast, use start
in cmd.exe
/ Start-Process
in PowerShell (whose built-in alias is also start
) to launch an executable in a new window (on Windows), asynchronously, with no (direct) ability to capture the launched executable's output:
From cmd.exe
:
start "title" "C:\Users\Bob Builder\Desktop\New Folder\test.exe"
Note:
Specifying "title"
- i.e. a self-chosen (console) window title - is required for syntactic reasons in this case: without it, the double-quoted path itself would be interpreted as the window title, and the - implied - executable to launch would be another cmd.exe
instance.
Note that if you launch a GUI application this way, the title argument is irrelevant, because no new console window is created.
Conversely, if you launch a console application specified by double-quoted path and therefore must use a title argument, note that ""
will result in the new window having no title.
From PowerShell (parameter -FilePath
is positionally implied):
Start-Process 'C:\Users\Bob Builder\Desktop\New Folder\test.exe'
Note:
Start-Process
does not support specifying a window title, so you may want to call cmd.exe
's internal start
command for that (or other features not supported by Start-Process
, such as specifying the process priority).
To work around quoting problems, invoke cmd.exe
's start
from PowerShell by passing the entire start
command as a single string to cmd /c
:
cmd /c 'start "title" "C:\Users\Bob Builder\Desktop\New Folder\test.exe"'