You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Automator需验证特定密码才可执行工作流?

Automator工作流添加密码验证方案

方法一:使用AppleScript实现

在Automator工作流最顶端添加「Run AppleScript」操作,替换为以下代码(记得把你的目标密码改成实际要验证的密码):

set correctPassword to "你的目标密码"
set inputPassword to text returned of (display dialog "请输入密码以继续运行工作流:" default answer "" with hidden answer)

if inputPassword is not equal to correctPassword then
    display dialog "密码错误,工作流终止。" buttons {"确定"} default button 1
    error number -128 -- 触发工作流终止
end if

运行时会弹出带隐藏输入的对话框,输入错误会终止工作流,输入正确则继续执行后续操作。

方法二:使用Shell脚本实现

在Automator工作流最顶端添加「Run Shell Script」操作,选择/bin/bash作为执行环境,替换为以下代码:

#!/bin/bash

CORRECT_PASS="你的目标密码"

read -sp "请输入密码以继续运行工作流:" INPUT_PASS
echo ""

if [ "$INPUT_PASS" != "$CORRECT_PASS" ]; then
    echo "密码错误,工作流终止。"
    exit 1
fi

执行时会弹出终端窗口(若工作流导出为应用形式)提示输入密码,输入错误直接退出,正确则继续后续步骤。

注意事项

  • 以上两种方案的密码均为明文存储在脚本中,若需要更高安全性,可结合macOS钥匙串管理存储和读取密码,但会增加实现复杂度。
  • 若介意终端窗口弹出,优先选择AppleScript方案。

内容的提问来源于stack exchange,提问作者John Smith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 16:45:55