Solved

Set Windows Process Priority through VB?

Posted on 2008-10-22
5
979 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Rick
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22777037
Are you using VB6 or .NET?

Kind regards,

Matthias Vance
0
 
LVL 13

Author Comment

by:Rick
ID: 22777278
I'm using VB 08, but I will take the answer in any version.

Thanks,
Rick
0
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22777685
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

0
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 500 total points
ID: 22777709
Updated code.
    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 = priority
        Next
    End Sub
 
SetProcessPriority("calc", ProcessPriorityClass.High)

Open in new window

0
 
LVL 13

Author Closing Comment

by:Rick
ID: 31508749
Excellent job!

Thank you,
Rick
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ms access #TYPE! error on report when no data 4 75
Windows 10 start screen issues 9 54
I need help formating a date variable in my VB.Net application 2 51
Hide vba in gp 7 93
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question