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

Heyah!

Im using the following code (in windows) to execute calc.exe

system("start \"c:\\WINDOWS\\system32\\calc.exe\"");

Im using "start" so that i opens as a new process, allowing my script to continue.

The thing is that it actually DOESNT open calc.exe ... but cmd.exe. No idea why. Where is my typo???

Replies are listed 'Best First'.
Re: system CALC.exe opens command prompt ??
by halley (Prior) on Sep 09, 2011 at 17:44 UTC

    No typo. Just Windows being stupid.

    Try the following two commands on your command line. Skip perl altogether.

    start c:\WINDOWS\system32\calc.exe start "c:\WINDOWS\system32\calc.exe" start /? [Enter] [Enter] start "" "c:\WINDOWS\system32\calc.exe"
    If the first argument is in double-quotes, it assumes that it's a window title, not a command.

    --
    [ e d @ h a l l e y . c c ]

      LOL, that was easy!.... im just used to tying it up like that if I ever get executables with space in them. Thanks! That worked..
Re: system CALC.exe opens command prompt ??
by ikegami (Patriarch) on Sep 10, 2011 at 01:24 UTC

    start has a *very* weird syntax. If the first argument has quotes, it's used as the console title. If you weren't able to drop the quotes, the workaround would be:

    system(q{start "" "C:\\...\\calc.exe"});

    Simpler:

    system(-1, "C:\\...\\calc.exe");
Re: system CALC.exe opens command prompt ??
by IvyR (Novice) on Sep 09, 2011 at 20:54 UTC
    Since calc is in the path by default, can you just call it without a path? If you go to the run prompt and just type "calc" you will get the calculator.