in reply to Re^7: Win32::Process - need help from an expert!
in thread Win32::Process - need help from an expert!

It'll work from the command line, because the command line can execute more than just programs. DOS has some builtin commands. But we're talking about CreateProcess, which runs programs.

Just like DOS can't execute Perl commands (e.g. print), Perl can't execute DOS commands (e.g. echo). echo is built in cmd.exe and command.com and not a program, so CreateProcess can't run it. However, just like you can run perl to execute Perl commands (perl -le "print 'Hello World'"), you can run cmd to execute DOS commands (cmd /c "echo Hello World").

Replies are listed 'Best First'.
Re^9: Win32::Process - need help from an expert!
by somuchh8 (Novice) on Sep 13, 2007 at 15:57 UTC
    I see what you mean. This is why I put the command into a bat file. Can perl not execute a bat file? I'll try using cmd.exe /c "echo hello world" and see if that works because my test does not create the hello world text file like it should. I appoligize for my newbness I am mostly a Unix / Linux programmer.

      Batch files are in the same boat. They're not executables. You need to launch them via cmd just like you would need perl to execute perl scripts. The documentation for CreateProcess specifically mention batch files.

      It's just like unix. To execute a bash script, you need to run bash. The difference is that unix provides an automatic mechanism (#!) to load up a script in the proper handler, whereas one must manually call the mechanism (start) in Windows.