Here's a command line driven Inline::C script. Supply the pid and required priority (idle/below/normal/above/high/realtime) as arguments. (Converting numeric priorities back to text for output left as an exercise.):

#! perl -sw use 5.010; use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => 'Priority', CLEAN_AFTER_BUILD => 0 +; HANDLE openProcess( SV *pid ) { HANDLE ph; if( !( ph = OpenProcess( PROCESS_ALL_ACCESS, 0, SvIV( pid ) ) ) ) croak( "Failed to open process pid:%d (See $^E)\n", SvIV( pid +) ); return ph; } SV *setPriorityClass ( SV *pid, SV* class ) { HANDLE ph = openProcess( pid ); if( !SetPriorityClass( ph, SvUV( class ) ) ) croak( "SetPriorityClass failed; See $^E \n" ); return class; } int getPriorityClass ( SV *pid ) { HANDLE ph = openProcess( pid ); DWORD class; if( !( class = GetPriorityClass( ph ) ) ) croak( "SetPriorityClass failed; See $^E \n" ); return class; } END_C use constant PRIORITY => { IDLE => 0x40, BELOW => 0x4000, NORMAL => 0x20, ABOVE => 0x8000, HIGH => 0x80, REALTIME => 0x100, }; my $old = eval{ getPriorityClass( $ARGV[ 0 ] ) } or die $^E; my $new = eval{ setPriorityClass( $ARGV[ 0 ], PRIORITY->{ uc $ARGV[ 1 ] } ) } or die $^E; say "Priority of process id: $ARGV[ 0 ] changed from $old to $new"; __END__ C:\test>priority 1460 idle Priority of process id: 1460 changed from 32 to 64 C:\test>priority 1460 below Priority of process id: 1460 changed from 64 to 16384 C:\test>priority 1460 normal Priority of process id: 1460 changed from 16384 to 32 C:\test>priority 1460 above Priority of process id: 1460 changed from 32 to 32768 C:\test>priority 1460 high Priority of process id: 1460 changed from 32768 to 128 C:\test>priority 1460 realtime Priority of process id: 1460 changed from 128 to 256

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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: Changing Windows Process Priority by BrowserUk
in thread Changing Windows Process Priority by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.