我执行了以下操作,并且工作正常,我将命令行工具添加到了项目的资源文件夹中,并执行了以下操作:
set myPath to POSIX path of (path to resource "MyComandLineTool")
do shell script "cp " & quoted form of POSIX path of myPath & space & "/private/tmp" with administrator privileges
set cmd to "/private/tmp/myPath -r"
do shell script " " & cmd with administrator privileges
我想知道如何不将其传递给/ private / tmp,只需在项目的Resources文件夹中运行它即可。
答案 0 :(得分:1)
这非常相似,只是省略了复制部分
set myPath to quoted form of (POSIX path of (path to resource "MyComandLineTool"))
do shell script myPath & " -r" with administrator privileges
注意:quoted form of
始终是一个好习惯,因为路径可能包含空格字符