in reply to Re: Call batch script in new command / DOS window
in thread Call batch script in new command / DOS window

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\"");

Replies are listed 'Best First'.
Re^3: Call batch script in new command / DOS window
by BrowserUk (Patriarch) on Aug 21, 2008 at 19:31 UTC
    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.

      scuse me for being 1 minute behind you in posting.

      I was just repeating that solution to make the node complete, not as an indication that there was a problem with the timing of your answer. Call it an inlined hyperlink if you wish.

      Nope! This works: system "start c:\\test\\DigThis.bat";

      I never said it didn't. I didn't say quotes were needed. You misquoted me. The fragment of my sentence you quoted was part of the condition ("If ... you need to use quotes, ...").

      But this doesn't! system("start \"\" \"c:\test\DigThis.bat\"");

      Only because the file doesn't exist. File names with tabs in them appear to be illegal in Windows. On the other hand, the following *does* work.

      system("start \"\" \"c:\\test\\DigThis.bat\"");