in reply to Re: More Perl/Tk Queries with Spawned Processes under Win32
in thread More Perl/Tk Queries with Spawned Processes under Win32

This suggestion works very well, with some modifications... many thanks for your help!

I'm not sure if I should put this next item in another question by itself... but as it's related to the current program...

It's always a bugbear that when using Win32::Process::Create, complete paths need to be specified in the call, rather than letting the PATH search mechanisms find the program I want to run.

In the current example, this means we have to specify the call like:

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

I'd like to know how people get around this problem, particularly when programs are placed in non-standard locations (although the programs may be found on PATH).

I've had a look in 'SuperSearch' but had no joy. One thought would be to collect the list of directories in PATH via File::Spec->path() and then use File::Find on the result. Alternatively, there seems to be a module on CPAN called File::PathList which (I think) returns the fully-pathed filespec directly.

Any other thoughts? ...and many thanks for any forthcoming suggestions :)

Replies are listed 'Best First'.
Re^3: More Perl/Tk Queries with Spawned Processes under Win32
by BrowserUk (Patriarch) on May 09, 2006 at 03:46 UTC

    You could allow the shell to do the path resolution for you:

    Win32::Process::Create( $obj, "C:\\windows\\system32\\cmd.exe", 'cmd /c notepad somefile', 0, NORMAL_PRIORITY_CLASS, '.' ) or die $^E;;

    Or more simply use system

    ## Run the command asyncronously with shell command resolution $pid = system 1, 'notepad'; .... ## Do other stuff ## Retrieve the exit code waitpid $pid, 0; print 'command return status: ', $? >> 8;; command return status: 0

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.