如何在 运行 时间使用 java 脚本 运行 一个 exe 文件

How to run an exe file using java script at runtime

我正在尝试使用量角器自动执行一些操作。我有一种情况需要处理 Windows 弹出窗口,我为此编译了一个 AutoIt 脚本 (.exe)。我可以在 Java 和 selenium 中在运行时导入它。我不确定如何在 Protractor 和 JavaScript 案例中做到这一点。谢谢

试试 NPM package/l shelljs

示例:

// Run external tool synchronously
if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
  shell.echo('Error: Git commit failed');
  shell.exit(1);
}

如果你想打开外部文件,那么你应该使用built-in child_process模块。

var { exec } = require("child_process");
//the function acts like a shell, so just use shell commands.
exec("cmd.exe");