在 Mac OS 10.10 上,我正在尝试创建已安装卷的别名并将别名放在用户的主文件夹中,以便以后可以将其放入扩展坞中。该卷是一个名为 satffdata$ 的 SMB 共享(它是一个隐藏的 Windows 共享,因此最后是 $)。我尝试了不同的路径变体,例如明确定义它并使用内置别名但无济于事。
请看下面的代码,然后输出。我得到的错误代码和我读过的内容表明问题可能是将路径视为字符串,但是我无法明确定义启动磁盘名称或用户配置文件,因为它们在当时可能不同脚本由我们的 Casper Suite 系统自动运行。
tell application "Finder"
activate
try
display dialog "Setting your StaffData$ (P Drive) Shortcut. Press OK to continue."
mount volume "smb://servername/staffdata$"
set staffData to POSIX path of "/Volumes/staffdata$"
set homeDir to POSIX path of (path to home folder)
display dialog staffData
display dialog homeDir
make new alias to staffData at homeDir
set name of result to "staffdata$"
end try
end tell
输出如下:
tell application "Finder"
activate
display dialog "Setting your StaffData$ (P Drive) Shortcut. Press OK to continue."
--> {button returned:"OK"}
mount volume "smb://servername/staffdata$"
--> error number -10004
end tell
tell application "Script Editor"
mount volume "smb://servername/staffdata$"
--> file "staffdata$:"
end tell
tell application "Finder"
display dialog "/Volumes/staffdata$"
--> {button returned:"OK"}
display dialog "/"
--> {button returned:"OK"}
make new alias to "/Volumes/staffdata$" at "/"
--> error number -10000
end tell
如果您有任何问题,我会尽快回复。谢谢!