![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | redirect powershell stdout to objShell.Exec.Stdout.ReadAll()( 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 |
My System Specs![]() |
| | #2 (permalink) |
| | Re: redirect powershell stdout to objShell.Exec.Stdout.ReadAll()( kanjasaha@xxxxxx wrote: Quote: > 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" help somewhat: http://blog.sapien.com/index.php/200...ed-powershell/ Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| objshell.exec exit code | VB Script | |||
| StdOut.ReadAll() in VBScript | VB Script | |||
| Problem with WSH Shell Exec StdOut | VB Script | |||
| StdOut.ReadAll blocking? | VB Script | |||
| stdout redirection | PowerShell | |||