Hi,
I have a similar problem I am dealing with. Hence posting in this
discussion chain.
I have a powershell script text.ps1
And then I have a .js file which is invoking this text.ps1 using WSH.
Here is the code:
------------------------------------------------------------------
var objShell = WScript.CreateObject("WScript.Shell");
var strCMD="powershell c:\\script\\text.ps1"
WScript.Echo (strCMD)
var objexec = objShell.Exec(strCMD)
WScript.Echo (objexec.status)
/**
WScript.Echo("stdout");
WScript.Echo(objexec.StdOut.ReadAll())
WScript.Echo("stderr");
WScript.Echo(objexec.StdErr.ReadAll())
WScript.Echo("ExitCode");
WScript.Echo(objexec.exitcode)
**/
--------------------------------------------------------
Even after the var objexec = objShell.Exec(strCMD) ran successfully, I
see the Exec.Status is 0.(The powershell window closed after the
execution)
And when I try to display WScript.Echo(objexec.StdOut.ReadAll()),
the .js script hangs and I have to do CTRL+C to get out to command
line.
Is it at all possible to redirect powershell stdout(which is an
object) to objShell.Exec.Stdout.ReadAll()(which is text I assume).
Thanks
Kanja


