ralijani has asked for the wisdom of the Perl Monks concerning the following question:

i use : system('c:\\program files\\my dir\\myfile.exe'); when i run it, it gives error : c:\program is not recognized az an internal or external command. my path is: c:\Program Files\My Dir\myfile.exe

Replies are listed 'Best First'.
Re: correct path
by bart (Canon) on Jun 10, 2004 at 14:05 UTC
    Put double quotes around the path — that's right: as part of the string.
    system('"c:\\program files\\my dir\\myfile.exe"');
Re: correct path
by eserte (Deacon) on Jun 10, 2004 at 13:22 UTC
    You have to escape the spaces with a single backslash.
Re: correct path
by Hena (Friar) on Jun 10, 2004 at 13:56 UTC
    Would suggest that you check out File::Spec::Functions. In this case this might work:
    Use File::Spec::Functions (qw/catfile rootdir/); my $path=catfile(rootdir(),'Program Files','My Dir','myfile.exe');
A reply falls below the community's threshold of quality. You may see it by logging in.