Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Launching processes with low priority?

Reply
 
Old 04-18-2009   #1 (permalink)
Thorsten Albrecht


 
 

Launching processes with low priority?

Is it possible in PS to influence the priority of a launched process
(like start /low in DOS)?

Thorsten

My System SpecsSystem Spec
Old 04-18-2009   #2 (permalink)
Vadims Podans [MVP]


 
 

Re: Launching processes with low priority?

If you have already launched application then you can change PriorityClass
property for process:

$a = gps powershell
$a.PriorityClass = "BelowNormal"

or with looping:
gps iexplore | %{$_.PriorityClass = "High"}

All acceptables values are here:
[vPodans] [Enum]::getNames("Diagnostics.ProcessPriorityClass")
Normal
Idle
High
RealTime
BelowNormal
AboveNormal

If you want to start a new process with custom priority, you can use
Win32_Process WMI class with ProcessPriority property (which represents
Win32_ProcessStartup class).
http://msdn.microsoft.com/en-us/libr...88(VS.85).aspx - Create Method
of the Win32_Process Class
http://msdn.microsoft.com/en-us/libr...75(VS.85).aspx -
Win32_ProcessStartup Class
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Thorsten Albrecht" <route-to-nowhere@xxxxxx> rakstija zinojuma
"news:h06ju4t7sl94pupp2pb9bhg6nn3ah17etl@xxxxxx"...
Quote:

> Is it possible in PS to influence the priority of a launched process
> (like start /low in DOS)?
>
> Thorsten
My System SpecsSystem Spec
Old 04-18-2009   #3 (permalink)
Uwe Kausch


 
 

Re: Launching processes with low priority?

Hi Thorsten,

I just know how to change the proiority of a running process. The simple version is ...
([wmi]'Win32_Process=172').SetPriority(16384)
at which 172 is the process id and 16384 is the new priority (see below).

To change multiple processes by a key value (e.g. process name) you can run this ...
Get-WmiObject Win32_process -filter 'name = "notepad.exe"' | foreach-object { $_.SetPriority(32) }

At last the list of priority codes ...
256 REALTIME
128 HIGH_PRIORITY
32768 ABOVE_NORMAL
32 NORMAL
16384 BELOW_NORMAL
64 IDLE

Good luck and regards from munich,
Uwe



Thorsten Albrecht wrote:
Quote:

> Is it possible in PS to influence the priority of a launched process
> (like start /low in DOS)?
>
> Thorsten
My System SpecsSystem Spec
Old 04-18-2009   #4 (permalink)
Alex K. Angelopoulos


 
 

Re: Launching processes with low priority?

And for completeness sake, you can also directly use
System.Diagnostics.Process. There's minor drilldown necessary, working with
the System.Diagnostics.ProcessStartInfo subitem, but it does provide the
ability to completely control every aspect of the started process.


http://msdn.microsoft.com/en-us/libr...s.process.aspx
http://msdn.microsoft.com/en-us/libr...startinfo.aspx

"Vadims Podans [MVP]" <vpodans> wrote in message
news:Ocs9nhAwJHA.3676@xxxxxx
Quote:

> If you want to start a new process with custom priority, you can use
> Win32_Process WMI class with ProcessPriority property (which represents
> Win32_ProcessStartup class).
> http://msdn.microsoft.com/en-us/libr...88(VS.85).aspx - Create
> Method of the Win32_Process Class
> http://msdn.microsoft.com/en-us/libr...75(VS.85).aspx -
> Win32_ProcessStartup Class
> --
> WBR, Vadims Podans
> MVP: PowerShell
> PowerShell blog - www.sysadmins.lv
>
> "Thorsten Albrecht" <route-to-nowhere@xxxxxx> rakstija zinojuma
> "news:h06ju4t7sl94pupp2pb9bhg6nn3ah17etl@xxxxxx"...
Quote:

>> Is it possible in PS to influence the priority of a launched process
>> (like start /low in DOS)?
>>
>> Thorsten
>
My System SpecsSystem Spec
Old 04-20-2009   #5 (permalink)
Thorsten Albrecht


 
 

Re: Launching processes with low priority?

Uwe Kausch <UweKausch.News@xxxxxx> wrote:
Quote:

>To change multiple processes by a key value (e.g. process name) you can run this ...
> Get-WmiObject Win32_process -filter 'name = "notepad.exe"' | foreach-object { $_.SetPriority(32) }
Hi Uwe

thanks. Another possibility would be to start the powershell shell
itself with lower priority. Thus all child processes have the same low
priority.

Thorsten
My System SpecsSystem Spec
Old 04-20-2009   #6 (permalink)
jasonmarcher


 
 

Re: Launching processes with low priority?

On Apr 18, 2:09*am, Thorsten Albrecht <route-to-
nowh...@xxxxxx> wrote:
Quote:

> Is it possible in PS to influence the priority of a launched process
> (like start /low in DOS)?
>
> Thorsten
(Oops, sent this the wrong way.)

$proc = [System.Diagnostics.Process]::Start("notepad.exe")
$proc.PriorityClass =
[System.Diagnostics.ProcessPriorityClass]::BelowNormal
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
CPU Priority for Processes Tutorials
launching/not launching programs upon logging in Vista General
Priority question Vista General
USB Priority Vista General
Codec Priority Vista music pictures video


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46