in reply to Proc::Background does not take file path with spaces

What happens when you escape the space?

my $Command = "C:\\Program Files\ (x86)\\vs.exe";

Improve your skills with Modern Perl: the free book.

Replies are listed 'Best First'.
Re^2: Proc::Background does not take file path with spaces
by Corion (Patriarch) on Apr 27, 2012 at 07:29 UTC

    The Windows command shell (cmd.exe) expects whitespace in arguments to be properly quoted, and "properly quoted" in its terms means to use double quotes to surround the file name.

    As double quotes treat the backslash special, single-backslashing a space character doesn't make much sense to me. I would try

    my $Command = q{"C:\Program Files (x86)\vs.exe"};

    or the double-quoted variant

    my $Command = qq{"C:\\Program Files (x86)\\vs.exe"};

      Corion is correct, this is the way to do it. I usually write a quick sub that will process command line arguments for me:

      sub argify { while (my $aref = shift) { @$aref = map "/"$_/"", @$aref; } }
      I tried the folllowing
      my $CommandNew = qq("C:\\Program Files (x86)\\vs.exe"); print "Command is $CommandNew\n"; my $ID = Proc::Background->new($CommandNew);

      ERROR: Test.pl: cannot find absolute location of "C:\Program

      Also tried
      my $CommandNew = q(C:\\Program Files (x86)\\vs.exe); print "Command is $CommandNew\n"; my $ID = Proc::Background->new($CommandNew);

      ERROR: Test.pl: no executable program located at C:\Program
      I am still stuck

        You are going to have to accept that Proc::Background is terminally broken and use something else.

        See Re: Proc::Background does not take file path with spaces for one such possibility.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

      I tried the folllowing
      my $CommandNew = qq("C:\\Program Files (x86)\\vs.exe"); print "Command is $CommandNew\n"; my $ID = Proc::Background->new($CommandNew);

      ERROR: Test.pl: cannot find absolute location of "C:\Program

      Also tried
      my $CommandNew = q(C:\\Program Files (x86)\\vs.exe); print "Command is $CommandNew\n"; my $ID = Proc::Background->new($CommandNew);

      ERROR: Test.pl: no executable program located at C:\Program
      I am still stuck