如何在Xcode中使用AppleScript创建简单的kext安装程序?

时间:2018-12-26 21:29:35

标签: xcode applescript

有人可以告诉我如何在Xcode中使用AppleScrit创建一个简单的Kexts安装程序吗? 我尝试了以下方法:

on installKext:sender  
choose file
copy the result to thisFile
copy the (info for thisFile) to fileInfo
copy the name extension of the fileInfo to nameExtension
copy the file type of the fileInfo to filetype
tell application "Finder"
    if the filetype is "Kext" or ¬
        the nameExtension is "Kext" then
        move thisFile to folder "Extensions" of folder "Library" of folder "System" of startup disk
    end if
end tell
end installKext:

我有此错误:

  

installKext:]:无权将Apple事件发送到Finder。 (错误   -1743)

     

错误域= PlugInKit代码= 13“查询已取消”   UserInfo = {NSLocalizedDescription =查询已取消}

2 个答案:

答案 0 :(得分:0)

您无法使用Finder将文件移动到属于系统的文件夹中。

您需要使用do shell script .... with administrator privileges的root特权

on installKext:sender  
    set theFile to choose file
    tell application "System Events"
        set {name extension:nameExtension, file type:fileType} to theFile
    end tell
    if fileType is "Kext" or nameExtension is "Kext" then
        do shell script "mv " & quoted form of POSIX path of theFile & space & "/System/Library/Extensions/" with administrator privileges
    end if
end installKext:

答案 1 :(得分:0)

您必须在info.plist中添加以下内容: enter image description here 现在,一切都像魅力一样。

相关问题