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

Howdy monks. I've got a system built up of several perl apps that run simultaneously. These all show up as "perl.exe" under the column "Image Name" in the Windows Task Manager process list. This is less than optimal for debugging purposes. Is there any way I can have each app set its Image Name to something meaningful? There doesn't seem to be an argument to perl.exe that will do the job. I found Win32::ToolHelp, but this only lets you to get, not set, process info.

Many thanks...

Steve

  • Comment on Setting Win32 "Image Name" of a Perl Process

Replies are listed 'Best First'.
Re: Setting Win32 "Image Name" of a Perl Process
by BrowserUk (Patriarch) on Aug 14, 2006 at 00:24 UTC

    Somebody may well prove me wrong on this, but I am unaware of any mechanism for changing the image name of a running Win32 process.

    The best suggestion I have is that you create a renamed copy of perl.exe for each application and a .cmd file with the same name that runs the appropriate .pl file using the appropriately named .exe. The executable is only ~40kb, so the space requirements are minimal. By placing the .cmd file (or a .bat create with pl2bat.pl with edits), in the path, you will be able to run yourapp.pl using the command line yourapp which will run yourapp.cmd, which will run yourapp.exe yourapp.pl.

    Not elegant, but simple to arrange, with minimal requirements, and it achieves the aim of having different names appear in the tasklist, whilst allowing each of those executables to share the majority of runtime ram because they would share the one instance of perl5x.dll.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Setting Win32 "Image Name" of a Perl Process
by GrandFather (Saint) on Aug 14, 2006 at 00:12 UTC

    It is not apparent that there is any way to set the Image Name. There is nothing passed into CreateProcess that seems related to the image name that is shown and there are no API functions that I can see that would allow you to change the image name once created - very likely that is by design!

    However if you look at the Applications tab rather than the Processes tab you may find that the names of things are more to your liking. For GUI apps you may find it helps to use wperl.exe rather than perl.exe to run your applications.

    This all assumes a context of Windows and, for wperl, ActiveState Perl of course.


    DWIM is Perl's answer to Gödel
      This all assumes a context of Windows and, for wperl, ActiveState Perl of course

      I think wperl.exe will be part of any properly built perl for Win32, irrespective of who built it or which compiler was used. (It's certainly part of my MinGW-built perl 5.8.8, which was built from the perl.org source.)

      Cheers,
      Rob
      ++ for "this is by design" ;)
Re: Setting Win32 "Image Name" of a Perl Process
by NetWallah (Canon) on Aug 14, 2006 at 03:28 UTC
    Perhaps you could convert the "long running apps" into Win32 SERVICEs. These have a lot more control, via registry keys, as to what they look like when running.

    The Windows resource kid provides "srvany", which helps launch any command line app as a service.

         "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken

Re: Setting Win32 "Image Name" of a Perl Process
by bunnyman (Hermit) on Aug 14, 2006 at 21:32 UTC

    I do not think you can do this.

    But there is still hope! Using Process Explorer you can view the command line arguments to the process. (Go to the View menu and choose "Select Columns")

    Presto, now you can easily tell which process is what.