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

I'd like to know if anyone knows a way inside a ActivePerl script on windows to find your own process id, and set the windows priority of that process.

Justin Eltoft

"If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

  • Comment on Can a perl script on windows set it's self priority level?

Replies are listed 'Best First'.
Re: Can a perl script on windows set it's self priority level?
by ikegami (Patriarch) on Dec 19, 2007 at 17:58 UTC

    Yes, SetPriorityClass in Win32::Process calls the system call with the same name.

    The code would look like

    use Win32::Process qw( HIGH_PRIORITY_CLASS ); Win32::Process::Open(my $proc, $$, 0) or die($^E); $proc->SetPriorityClass(HIGH_PRIORITY_CLASS) or die($^E);

    Update: Added parameter missing from call to Open, as mentioned in a reply.

      Awesome! Thanks! Note that I had to add one more parameter to the call to Win32::Process::Open(). For activestate, it takes "iflags" as third parameter.

      $iflags flag: inherit calling processes handles or not

      Justin Eltoft