in reply to Re: Re: Win32::Process redirect CMD output to text file
in thread Win32::Process redirect CMD output to text file

Here, look at this
use Win32::Process; Win32::Process::Create($ProcessObj, 'c:\winnt\system32\cmd.exe', "/c echo foo>foo.txt", 0, NORMAL_PRIORITY_CLASS,".")||warn "could not create process";
instead of echo foo put in the program you want to run. Win32::Process is doing what you ask of it - it is creating a process running "identify.exe". "indentify.exe" does not know how to redirect. You have to run "cmd.exe" and have it start "identify.exe" and redirect the output to a file. system transparently starts a shell (cmd.exe) and hands it the parameters, the first of which is the program it should run. Most people from a windows background don't understand that a command prompt is actually a program called "cmd.exe" (or "command.com" on dos/win9x)

Update:
Note: the name of your shell is probably available in $ENV{COMSPEC}

--

flounder

Replies are listed 'Best First'.
Re: Re^3: Win32::Process redirect CMD output to text file
by sdyates (Scribe) on Jun 25, 2002 at 17:32 UTC

    It is always sonething simple!!! Thanks so much... Thinking too much in one way. Now I just have to solve my other bugs :)

Re^4: Win32::Process redirect CMD output to text file
by Anonymous Monk on Jan 06, 2006 at 09:38 UTC
    Starting Process and redirecting output works well, but another problem arises: I cannot kill the process started by cmd i.e. identify.exe. Only the cmd.exe is killed, identify.exe continues. Thanks for any help

      Starting Process and redirecting output works well, but another problem arises: I cannot kill the process started by cmd i.e. identify.exe. Only the cmd.exe is killed, identify.exe continues

      i also have the same problem....did you find the solution? i want to kill identify.exe ...but its satarting and killing cmd.exe