|
|
||||||
|
#1
|
|
|
|
|
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 |
|
|
|
#2
|
|
|
|
|
kanjasaha wrote:
> 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" You're not calling powershell.exe properly for starters. This should help somewhat: http://blog.sapien.com/index.php/200...ed-powershell/ Marco |
|
|
| Similar Threads | |
| StdOut.ReadAll() in VBScript I am writing a script to read user names from a txt file then run the calcs command on their application data folder in their home dir to check their permissions. If they... |
|
| How to use fork-exec system call to redirect stdout/stderr to a buffer? Hi there I am a beginner for system programming, I'd like to use fork-exec programming to perform a "C-code compilation" and see if any compilation errors within... |
|
| Redirect stdout, stderr to file and stdout I have a small script that does some admin work for me. What I need to do now is not only have is display information to STDERR and STDOUT but also write the same... |
|
| Wsh.exec hangs getting StdOut.ReadAll from command line Winzip I'm trying to write a simple backup script. I'd like to use wsh.exec to run the command line Winzip to create a zip file and capture the StdOut and write it to a log. It... |
|
| How to redirect stdout to a file with fork-exec? Greetings, I writing a fork-exec program as: if ((pid = fork()) == 0) { // Question here: how a redirect exec-ing process's output to a file? exec(); } |
|
|
All times are GMT. The time now is 06:08 PM. | Privacy Policy
|