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

From a perl script, how do I call a batch or command file that opens in a new Command / DOS window?
system("C:\\Foo\\DigThis.bat);
opens the batch file, but in the existing screen.
Do you believe in miracles? Yes!

Replies are listed 'Best First'.
Re: Call batch script in new command / DOS window
by BrowserUk (Patriarch) on Aug 21, 2008 at 18:26 UTC
      That won't wait for the child to complete like system normally does, and it won't work if the path contains quotes.

      If the OP wants to wait for the child to finish, I've already presented the solution.

      system("start /wait \"c:\program files\prog\prog\"");

      If the OP doesn't want to wait for the child to finish and you need to use quotes, you need to specify any other argumennt in order to avoid an ambiguity in start's parameter parsing.

      system("start \"\" \"c:\program files\prog\prog\""); -or- system("start /normal \"c:\program files\prog\prog\"");
        I've already presented the solution

        'scuse me for being 1 minute behind you in posting.

        If the OP doesn't want to wait for the child to finish

        Since he didn't specify, I pointed him at the documentation.

        and you need to use quotes,

        Nope! This works:

        c:\test>type DigThis.bat @echo I'm diggin' it c:\test>p1 [0] Perl> system "start c:\\test\\DigThis.bat";;

        But this doesn't!

        [0] Perl> system("start \"\" \"c:\test\DigThis.bat\"");

        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.
Re: Call batch script in new command / DOS window
by ikegami (Patriarch) on Aug 21, 2008 at 18:25 UTC
    system("start /wait C:\\Foo\\DigThis.bat");