javascript - How to use SystemWorker to execute PowerShell commands? -


i'm trying achieve systemworker of wakanda server-side api. cannot achieve it. i'm sure missing on workflow of systemworker.

i want launch powershell windows , run 2 commands inside. manually, run powershell in cmd.exe , can start write powershell commands , data.

in wakanda have set ssjs file code:

var powershell = new systemworker(['powershell'],null);  powershell.postmessage('add-type -assemblyname "presentationcore"'); powershell.endofinput(); powershell.postmessage('[windows.media.fonts]::systemfontfamilies'); powershell.endofinput();  powershell.onmessage = function (event) {     var data = event.data;     debugger; }; powershell.onerror = function (event) {     debugger; }; powershell.onterminated = function (event) {     // potentially check event.exitstatus or event.forced     debugger;     exitwait(); }; wait(); 

i have systemworkers.json file containing this:

[     {         "name" : "powershell",         "executable" :         [             { "path" : "c:\windows\system32\windowspowershell\v1.0\powershell.exe" }         ]     } ] 

i want execute 2 commands add-type -assemblyname "presentationcore" , [windows.media.fonts]::systemfontfamilies in powershell list of fonts available on machine.

if task manager, powershell launched, never achieve execute 2 command lines or data. achieve end in onterminated callback.

what missing?

finally reach make work.

now put command in ps1 file give argument systemworker

so :

var powershell = new systemworker(['powershell "c:/users/<myname>/desktop/<myscript>.ps1"'],null);  powershell.onmessage = function (event) {  }; powershell.onerror = function (event) { }; powershell.onterminated = function (event) {     exitwait(); }; wait(); 

i think more easy way commands in 1 file , ask system worker execute powershell , run script.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -