For there to be a deficiency with this particular aspect of Win32::Process::Create, 
there would also need to be a deficiency with the underlying CreateProcess() Win32 
API.  The actual cause here is the omission of "notepad" in the $appname argument.

Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir)
    Creates a new process. 

    Args:

        $obj            container for process object
        $appname        full path name of executable module
        $cmdline        command line args
        $iflags         flag: inherit calling processes handles or not
        $cflags         flags for creation (see exported vars below)
        $curdir         working dir of new process

    Returns non-zero on success, 0 on failure.

## example from Win32::Process docs

Win32::Process::Create($ProcessObj,
  "C:\\winnt\\system32\\notepad.exe",
  "notepad temp.txt",
  0,
  NORMAL_PRIORITY_CLASS,
  ".")|| die ErrorReport();

-----Original Message-----
From: Erik Felton [mailto:[EMAIL PROTECTED]
Sent: Friday, October 01, 2004 12:08 PM
To: perl-win32-users
Subject: Win32::Process::Create Sillyness!


Hello,
        I've checked the mailing list archive on active state and I can
find no reference of my issue ever being mentioned.  If it has, I
apologize in advance for covering old ground.

Anyway, I just found what IMHO is a deficiency with
Win32::Process::Create.  The 3 parameter (arguments passed to the
executable) needs to have a leading space.  Otherwise, as far as I can
tell, the argument is ignored.

For Example, here is some code that is basically copied from the
document page
http://aspn.activestate.com/ASPN/docs/ActivePerl/site/lib/Win32/Process.
html
This code will not work. It will merely open Notepad with a blank
document.

---------------------
use Win32::Process;
use Win32;
sub ErrorReport{
    print Win32::FormatMessage( Win32::GetLastError() );
}

Win32::Process::Create($ProcessObj,
                            "C:\\windows\\system32\\notepad.exe",
                            "c:\\helloworld.txt",
                            0,
                            NORMAL_PRIORITY_CLASS,
                            ".")|| die ErrorReport();

$ProcessObj->Wait(INFINITE);
---------------------

This code, on the other hand, will open the hellowworld.txt file.

---------------------
use Win32::Process;
use Win32;
sub ErrorReport{
    print Win32::FormatMessage( Win32::GetLastError() );
}

Win32::Process::Create($ProcessObj,
                            "C:\\windows\\system32\\notepad.exe",
                            " c:\\helloworld.txt",  #NOTE, leading space
                            0,
                            NORMAL_PRIORITY_CLASS,
                            ".")|| die ErrorReport();

$ProcessObj->Wait(INFINITE);
---------------------

Can someone explain to me why Win32::Process::Create behaves this way?

Thank you
Erik Felton

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to