從輸入文本中獲取價值?

傑姆斯

我想編寫一個 HTA JScript,它忽略輸入文本字段的值,並在按下 Enter 按鈕時執行 callShellApplication(結合 echo 命令的值和輸入文本字段的值)。

這是我已經擁有的代碼片段:

<label for="uname">Command: </label>
    <input type="text" style="color:black; id="command" name="name" required size="20"
           pattern="[a-z]{4,8}">
    <button onclick="callShellApplication('cmd /d /c echo/ &[The value of the text field should be entered here]')">Enter</button>

我可以在那裡做什麼?

更新:我通過從 hta 文件啟動批處理文件(使用 2 個命令)解決了這個問題。

黛布達斯

您可以使用子進程模塊api直接調用shell腳本(節點js後端js)

例如。

var exec = require('child_process').exec, child;

child = exec('cat *.js bad_file | wc -l',
    function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
             console.log('exec error: ' + error);
        }
    });
 child();

您可以根據需要自定義此代碼

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章