Spaces Cause Split in Path with PowerShell

We can call an executable by using its absolute path. The path can be like “C:\Windows Services\backup.exe”. This creates the error like below. This error is also named as spaces cause split in path . In this tutorial we examine how to solve this error.

Use Double Quotos

Double quotos are the first solution in order to solve the “split in path” error. The double quoto simply makes the provided string a complete single value and the spaces are not interpreted as different commands.

PS>"C:\Windows Services\backup.exe"

Use Single Quotos

The single quotos are very similar to the double quotos.

PS>'C:\Windows Services\backup.exe'

Use & Call Operator

PowerShell provides the & call operator which interprets the provided string and as its is expressed. The string is not interpreted in PowerShell way. In the following example we call the backup.exe without a problem like “spaces cause split in path”.

PS> & C:\Windows Services\backup.exe

Another popular case for this error is the “Program Files”. In the following example we prevent the “split in path” error for the “Program Files.

PS> & "C:\Program Files\Nmap\nmap.exe"

Leave a Comment