Link to home
Start Free TrialLog in
Avatar of Rick
Rick

asked on

Set Windows Process Priority through VB?

Hello,

Is there a way to set a windows process priority through VB (lower/higher its priority)?

What if there are two processes with the same name?
For example, two instances of ms word (winword)?

Thanks,
Rick
Avatar of MatthiasVance
MatthiasVance
Flag of Netherlands image

Are you using VB6 or .NET?

Kind regards,

Matthias Vance
Avatar of Rick
Rick

ASKER

I'm using VB 08, but I will take the answer in any version.

Thanks,
Rick
Here's some example code, I hope it helps you.

Kind regards,

Matthias Vance
    Private Sub SetProcessPriority(ByVal processName As String, ByVal priority As ProcessPriorityClass)
        Dim pl() As Process = Process.GetProcessesByName(processName)
        For Each p As Process In pl
            p.PriorityClass = ProcessPriorityClass.High
        Next
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of MatthiasVance
MatthiasVance
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rick

ASKER

Excellent job!

Thank you,
Rick