cmd icon indicating copy to clipboard operation
cmd copied to clipboard

How to deal with space in path when execute command in windows?

Open catfishlty opened this issue 3 years ago • 0 comments

For example:

Ex.1

c := cmd.NewCommand(`"C:\Program Files\Java\jre1.8.0_192\bin\java.exe" --version`)
    _ = c.Execute()
    fmt.Println(c.Stdout())
    fmt.Println(c.Stderr())
'\"C:\Program Files\Java\jre1.8.0_192\bin\java.exe\"' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

Plz focus on the path string. And I don't know why \" instead of "

Ex.2

c := cmd.NewCommand(`C:\Program Files\Java\jre1.8.0_192\bin\java.exe --version`)
    _ = c.Execute()
    fmt.Println(c.Stdout())
    fmt.Println(c.Stderr())
'C:\Program' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

Ex.1 and Ex.2 can solve by define the workingDir

Ex.3

When some problem need an arguments with a windows style file with space, the error occurs. And I didn't find the way to solve it.

Plz help~

catfishlty avatar Dec 01 '21 06:12 catfishlty