Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Call batch script in new command / DOS window

by Olaf (Acolyte)
on Aug 21, 2008 at 17:50 UTC ( [id://705902]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://705902]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2026-03-11 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.