in reply to Re: Problem with System() command in perl?
in thread Problem with System() command in perl?

yes I already looked into that. he's opening calculator through its main .exe file that is why it is working. but for some weird reason I have to open it from the shortcut that is why I used that path in system call. how can we do the same operation when invoking calculator through shortcut??? any suggestions???

  • Comment on Re^2: Problem with System() command in perl?

Replies are listed 'Best First'.
Re^3: Problem with System() command in perl?
by marto (Cardinal) on Oct 07, 2016 at 10:58 UTC

    It'd be helpful if you didn't ignore things. It doesn't matter if you call the .exe directly or not. You seem to have a lot of "wired reasons" for doing things and making life difficult for yourself.

    use strict; use warnings; use Win32; use Win32::GuiTest qw(:ALL); my $calc = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\ +\Accessories\\Calculator.lnk"; print "nothing else will happen until you close calc.exe\n"; system($calc); print "you closed calc.exe, moving on...\n"; print "using `start` to launch calc.exe will return once calc.exe is l +oaded\n"; system('start "" "' . $calc . '"'); print "\n\nyep, still running!\n\n";

      it is working thanks but I dint understand the system call.

      system('start "" "' . $calc . '"');

      could you please help me out with that?

        ankit.tayal560 - type start /? in a windows command prompt for more information on what marto is trying to impart.

        basically there are 3 ways to start new processes in perl:

        • open - open (IN, "program.exe|") or die "couldn't start program.exe"
        • system - system('program.exe')
        • backticks or qx - qx(program.exe) or `program.exe`

        careful what you do when running programs that require external input from users, but in a nutshell what's happinging in system('start "" "' . $calc . '"'); is the same as system('program.exe arg1');

        Cheers,
        Shadowsong