Search code examples
androidwindowsbatch-filecmdadb

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


Solution

  • 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..!!