我正在尝试创建一个脚本,该脚本将获取Mac的序列号并将其设置为HostName,LocalHostName和& ComputerName没有提示输入管理员凭据。到目前为止,这就是我所拥有的,并试图通过它。
如何在不提示的情况下将脚本中的凭据放到提取信息的位置?
set sys to do shell script "/usr/sbin/system_profiler SPHardwareDataType " without altering line endings
set StringVariable1 to "Serial"
set Serial_Number to do shell script "/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial/ { print $NF }' "
do shell script "scutil --set HostName " & Serial_Number with administrator privileges
do shell script "scutil --set LocalHostName " & Serial_Number with administrator privileges
do shell script "scutil --set ComputerName " & Serial_Number with administrator privileges
display dialog "The Mac has been renamed to " & Serial_Number