Can anyone please explain why it is that the following program will run as expected:
use strict; use Win32::Process; use Win32; Win32::Process::Create($Win32::Process::Create::ProcessObj, "/my files/jim/perl monks/tkwarn.exe", # path to executable '', # command line args 0, # Don't inherit stuff DETACHED_PROCESS, # flags for creation "C:/my files/jim/perl monks") or # current dir. die print_error(); sub print_error() { return Win32::FormatMessage( Win32::GetLastError() ); }
Yet, if I make a slight change:
"C:/my files/jim/perl monks/tkwarn.exe", # path to executable
I get the error message:
The system cannot find the file specified.
Now ordinarily I wouldn't think this was so strange, except the Perl Cookbook has the example:
# loader - starts Perl scripts without the annoying DOS window use strict; use Win32; use Win32::Process; # Create the process object. Win32::Process::Create($Win32::Process::Create::ProcessObj, 'C:/perl5/bin/perl.exe', # Whereabouts of Perl 'perl realprogram', # 0, # Don't inherit. DETACHED_PROCESS, # ".") or # current dir. die print_error(); sub print_error() { return Win32::FormatMessage( Win32::GetLastError() ); }
I wondered if the "current dir" path I gave would cause a similar problem so I gave an invalid directory for "current dir" and received an error message:
The directory name is invalid.
So . . . it likes "C:" in the current dir spec, but not in the executable file spec? If anyone could help me to understand this I would be most grateful.

"It is much more comfortable to be mad and know it, than to be sane and have one's doubts." -- G. B. Burgin


In reply to No useful device on path to madness by jlongino

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.