我在PowerShell中有一组脚本.我用.HTA构建了一个GUI,但我正在迁移到类似于NODE.js的方法.
我有一个工作脚本,但我必须进行修改以解决丢失的功能以从命令行获取输入.我曾经看到CMD提示窗口出现在我看到所有输出的位置,如果有提示符(Read-Host),用户可以与它进行交互.为了解决这个问题,我现在[Microsoft.VisualBasic.Interaction]::InputBox()用来在需要时从用户那里获得输入.
我尝试使用时遇到了问题,child.stdin.write();因为我的PowerShell进程只是挂起.它不会回应我的意见.
我已经尝试过在网上找到的每一个答案,但没有成功.在生产中调用的脚本是一个长时间运行的过程,具体取决于所选的任务,它将花费20分钟到3个小时.
所以,问题是,我无法让child.spawned进程发送输入,或者PowerShell不接受来自stdin的输入.
感谢您的帮助.
码:
HTML:
<button type="button" id="btn_ExecuteReport">Run Report</button>
<button type="button" id="btn_StopReport" >Stop Report</button>
<button type="button" id="btn_SendInput" >Send this...</button>
<h2>Results:</h2>
<p id="result_id">...</p>
<br/>
Run Code Online (Sandbox Code Playgroud)
JS(使用Electron v 0.31.0,io.js v 3.1.0,jQuery v 1.7.2):
$(document).ready(function () {
$("#btn_ExecuteReport").click(function (event) {
event.stopPropagation();
global.$ = $;
var remote = require('remote');
// to get some paths depending on OS
var app = remote.require('app');
//clipboard
var clipboard = require('clipboard');
var shell = require('shell');
// for choosing a folder
var …Run Code Online (Sandbox Code Playgroud)