Home > Software engineering >  Can i run a exe with cmd or powershell if i have spaces in username?
Can i run a exe with cmd or powershell if i have spaces in username?

Time:10-17

Ex:

cmd /C start C:\Users\Bob Builder\Desktop\New Folder\test.exe

I'm trying to use cmd to start a file but since there are spaces in the path, cmd is throwing an error after Bob.

Error:

"Windows cannot find C:\Users\Bob. Make sure you typed the name correctly, then try again."

The system cannot find the file C:\Users\Bob.

Its simply failing to accept the spaces. It's driving me crazy because I'm spoiled with C# working out of the box. I don't know much about this, I have been spending way too much time trying to figure this out. Some help would be greatly appreciated.

CodePudding user response:

cmd /C start "C:\Users\Bob Builder\Desktop\New Folder\test.exe"

Quotes are your friend. Sometimes even double quotes are too!

CodePudding user response:

Seems like cmd won't work for me. Powershell worked with this script:

$env:Path  = ";C:\Users\Bob Builder\Desktop\New Folder\"
test.exe
  • Related