Difference between Run() and ShellExecute()

空扰寡人 提交于 2019-11-26 18:38:22

问题


I want to execute something in a shell/terminal on Windows via AutoIt. And I know that there are two ways of doing it. For example:

Run(@ComSpec & " /c " & $myCommand, "", @SW_HIDE)
;and
ShellExecute($myCommand)

I don't understand the difference; both functions will do what I want, but what's behind them? Which pros and cons do they have?


回答1:


Run() is used to fire off executable files only. It requires the full path of the program.

ShellExecute() also accepts content files like .txt, .htm and .docx and will start the executable associated with it. The verb option can be used to control what action to perform on the file. It utilizes the Windows ShellExecute API.

References:
AutoIt Wiki - FAQ - How can I run something that is not an exe file…



来源:https://stackoverflow.com/questions/39175170/difference-between-run-and-shellexecute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!