AppleScript:尝试检索服务器的磁盘时出错



我正在尝试测试服务器(我的NAS(是否已安装。我不能使用磁盘的名称,因为AppleScript返回了NAS卷的名称,而不是NAS的名称,所以我尝试了:

tell application "Finder"
    tell application "System Events" to set theVolumes to every disk
    repeat with thisVolume in theVolumes
        set isLocal to thisVolume's local volume
        if (not isLocal) then
            set thisDisk to thisVolume's server -- > unable to coerce the data to the desired type
        end if
    end repeat
end tell

脚本调试器返回以下错误:无法将数据胁到所需的类型

谢谢。

代码完全属于 System Events。发现器根本不涉及。

发生错误是因为您尝试在Finder告诉块中解决System Events术语。用System Events替换Finder,然后在第二行中删除tell零件。

tell application "System Events"
    set theVolumes to every disk
    repeat with thisVolume in theVolumes
        set isLocal to thisVolume's local volume
        if (not isLocal) then
            set thisDisk to thisVolume's server -- > unable to coerce the data to the desired type
        end if
    end repeat
end tell

最新更新