There is a problem with the incoming execution command under exec.Command wins. The error window pops up. How to make it not pop up the error window?

the following two sentences, the first sentence can open the browser normally, the second sentence pops up an error dialog box, click OK is useless, can not be closed. The problem is the second sentence, how to not let it pop up the dialog box, but return the error to err.

err := exec.Command("cmd", "/c","start chrome http://www.baidu.com").Run()
err = exec.Command("cmd","/c", "start luanxie ").Run()

error screenshot
1537488492834616348.png

purpose: use the cmd command to call the chrome browser, now how the client does not install the chrome browser, will pop up this dialog box, click to make sure the dialog box can not be closed, you give some good methods,

Jul.08,2021

you can get the PATH environment variable, and then loop to see if each path exists in chrome.exe. When none of them exist, it is proved that


description of the solution using registry method: brief
Thank you, God's reply

Menu