我有c#桌面应用程序。 这个程序具有使用本地服务和管理过程的功能。 因此在客户端的管理员环境中运行。 我想使用节点模块将此应用程序更改为Web应用程序。 但是我有问题。 需要使用Powershell脚本访问Web应用程序中的客户端计算机。 前端使用React js。 但是我无法在我的React应用程序中运行Powershell脚本。 这是我的代码。
import $ from 'jquery';
class ChartSetting extends Component {
state = { }
componentDidmount(){
$(document).ready(() => {
// Create the PS Instance
const Shell = require('node-powershell').spawn;
const ps = new Shell({
executionPolicy: 'Bypass',noProfile: true
});
ps.addCommand('echo node-powershell');
ps.invoke()
.then(output => {
console.log(output);
})
.catch(err => {
console.log(err);
});
})
}
错误
jquery.js:3850 Uncaught TypeError: Shell is not a constructor
at HTMLDocument.<anonymous> (ChartSetting.jsx:23)
at mightThrow (jquery.js:3557)
at process (jquery.js:3625)