1

I have c# desktop application. This app have function that use local serviec and manage process. Thus run in administrator environment for client. I want to change this app to web app using node module. But I have issue. Need use powershell script to access client computer in web app. FrontEnd use React js. But I can't run powershell script in my react app. This is my code.

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);
        });

    })
}

Error

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)
JinCheng Jin
  • 11
  • 1
  • 2

0 Answers0