cmd
cmd copied to clipboard
How to deal with space in path when execute command in windows?
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~