我已经创建了一个applescript来从雪豹引导到狮子,但是bless命令失败了。下面是命令:
do shell script "bless -mount /Volumes/bootdrive/ -legacy -setBoot -nextonly" password "mypassword" with administrator privileges在重新启动时,我得到黑屏和“没有可启动的设备”错误。我以root (而不是applescript)身份直接在终端中运行该命令,并得到了相同的结果。是的,我已经三次检查了我使用的磁盘路径是正确的,并且是可引导的。
你知道问题出在哪里吗?
发布于 2013-04-12 04:27:01
我没有合适的设置来进行测试,但是-legacy选项在我看来非常可疑。根据the man page的说法,这是用来支持基于基本输入输出系统的操作系统,而OS不是。试着删除-legacy,看看它是否能更好地工作。
发布于 2021-10-18 13:50:07
工作解决方案
SIP是我在Big Sur遇到的第一个问题。把它关掉看起来不是个好主意。第二个问题是目标卷列表项没有操作。这使得不可能通过点击或“点击”功能来点击它们,可能是因为Big Sur上的一些新的额外保护。由于新的MacOS限制,单击AST和其他脚本也不起作用。我发现的唯一方法是使用python click(但这会导致脚本选择目标音量时稍微延迟)。
所以这是一个全自动的切换:
property targetVolume : "BOOTCAMP" # find name of required volume inside System Preference > Startup Disk
property passwordValue : "yourSystemPassword" # Can be empty
tell application "System Events"
tell application "System Preferences"
set current pane to pane id "com.apple.preference.startupdisk"
activate
end tell
tell application process "System Preferences"
tell window "Startup Disk"
set volumePosition to {0, 0}
set lockFound to false
# Check if auth required
set authButtonText to "Click the lock to make changes."
if exists button authButtonText then
click button authButtonText
# Wait for auth modal
set unlockButtonText to "Unlock"
repeat
if (exists sheet 1) and (exists button unlockButtonText of sheet 1) then exit repeat
end repeat
# Autofill password if setted
if passwordValue is not equal to "" then
set value of text field 1 of sheet 1 to passwordValue
click button unlockButtonText of sheet 1
end if
# Wait for auth success
repeat
if exists button "Click the lock to prevent further changes." then exit repeat
end repeat
end if
# Wait until loading volumes list
repeat
if exists group 1 of list 1 of scroll area 1 then exit repeat
end repeat
# Click on target volume (posible a slight delay because of shell script executing)
repeat with m in (UI element of list 1 of scroll area 1)
if (value of first static text of m = targetVolume) then
tell static text targetVolume of m
set volumePosition to position
end tell
end if
end repeat
set volumePositionX to item 1 of volumePosition
set volumePositionY to item 2 of volumePosition
my customClick(volumePositionX, volumePositionY)
click button "Restart…"
# Wait for restart modal appears
repeat
if (exists sheet 1) and (exists value of first static text of sheet 1) then exit repeat
end repeat
click button "Restart" of sheet 1
end tell
end tell
end tell
# shell script to make click work on target volume
on customClick(x, y)
do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
END"
end customClick
on simpleEncryption(_str)
set x to id of _str
repeat with c in x
set contents of c to c + 100
end repeat
return string id x
end simpleEncryption
on simpleDecryption(_str)
set x to id of _str
repeat with c in x
set contents of c to c - 100
end repeat
return string id x
end simpleDecryption您只需更改targetVolume和passwordValue.的两个属性密码可以为空,在这种情况下,您可以手动提供密码。然后只需复制此脚本,将其粘贴到脚本编辑器,并通过文件->导出->文件格式-应用程序导出,选择仅运行->保存。您可以对您拥有的所有系统执行相同的过程,例如Big Sur 1、Big Sur 2、Bootcamp。
https://stackoverflow.com/questions/15956978
复制相似问题