简体   繁体   中英

Run CMD command with file with spaces

When I try to acess a file with spaces and then give them arguments, it doesn't recognize the path. If I type following it works:

C:\Users\Valentino>cmd /C adb push "C:\Users\Valentino\Desktop\Test.dat" "/sdcard/"

[This works]

If I try following, doesn't:

C:\Users\Valentino>cmd /C "C:/Path With Spaces/adb" push "C:\Users\Valentino\Desktop\Test.dat" "/sdcard/"

[Here it says 'C:/Path' doesn't is a valid file]

Neither this:

C:\Users\Valentino>cmd /C "adb" push "C:\Users\Valentino\Desktop\Test.dat" "/sdcard/"

[Here it says that the syntax is incorrect]

How must the syntax be, in order to read that file with spaces and give them arguments?

EDIT: You can try this even if you haven't adb installed. You will se that it will always fail, even on a existing file

For using cmd command you need to use "Your File Name" ..

Here is an example..

keytool -exportcert -alias "your name" -keystore C:\Users\Desktop\your.keystore | C:\openssl-0.9.8k_X64\bin\openssl sha1 -binary | C:\openssl-0.9.8k_X64\bin\openssl base64

Edited : You can use below command for path in cmd :

cd "Path With Spaces"

For more detail, Refer this link and accepted answer..!!

How to use spaces in CMD?

Hope It will help you.

Thanks..!!

As explained here you can run cmd like one of this:

cmd /C ""C:/Path With Spaces/adb" push C:\Users\Valentino\Desktop\Test.da /sdcard/"

or

cmd /C ""C:/Path With Spaces/adb" "push" "C:\Users\Valentino\Desktop\Test.da" "/sdcard/""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM