System Priority

Discussion in 'Windows 7 Help and Support' started by sdruley, Aug 16, 2012.

  1. sdruley

    sdruley New Member

    Joined:
    Dec 14, 2011
    Messages:
    40
    Likes Received:
    1
    I have an important app running in Excel that takes 7 hours to complete. During that time the focus of the app is somehow diverted to something else in the Windows environment. When this happens the Excel program stops in its tracks until I click on it to give it back the focus.
    How can I increase the priority of Excel in the scheme of things so that this doesn't happen?
     
  2. patcooke

    patcooke Microsoft MVP
    Staff Member Premium Supporter Microsoft MVP

    Joined:
    May 16, 2010
    Messages:
    5,454
    Likes Received:
    268
    You can do but be aware that it can cause stability problems:

    1. Open task manager (Ctrl/Shift/Esc).

    2. Right click the application you want to prioritise, "Go to Process."

    3. Right-click the process, "Set Priority". Choose from the range "realtime" (highest) to low (lowest).
     
  3. sdruley

    sdruley New Member

    Joined:
    Dec 14, 2011
    Messages:
    40
    Likes Received:
    1
    Pat,
    Your response was timely and professional. I would like to know if there is a way to set up a bat file to do the above.

    Steve
     
  4. patcooke

    patcooke Microsoft MVP
    Staff Member Premium Supporter Microsoft MVP

    Joined:
    May 16, 2010
    Messages:
    5,454
    Likes Received:
    268
    You could use the start command in a batch file using this format:

    start /priority path

    where priority is one of the range given above (realtime to low) and path is the full address of the application, eg:

    start /high %windir%\system32\notepad.exe

    would run the notepad utility with a priority of high.

    In this case call the batch file something like runNotepad.bat.
     
  5. sdruley

    sdruley New Member

    Joined:
    Dec 14, 2011
    Messages:
    40
    Likes Received:
    1
    So, I can run your suggested bat in the following vba code...

    Code:
    Sub ExecuteBAT()Dim wshThisShell As WshShell
    Dim lngRet As Long
    Dim strShellCommand As String
    Dim strBatchPath As String
    Set wshThisShell = New WshShell
    strBatchPath = "start /high %windir%\C:\TTND\Picasso.xlsm"
    strShellCommand = """" & strBatchPath & """"
    lngRet = wshThisShell.Run(strShellCommand, vbNormalFocus, vbTrue)
    End Sub
    Does this look right to you?

    Steve


    -------------------------------------------------------------------------------------------------------------
     
  6. sdruley

    sdruley New Member

    Joined:
    Dec 14, 2011
    Messages:
    40
    Likes Received:
    1
    Pat, I now have the following; but I am still getting the run time error -2147024894 (80070002) Automation error at the last line of code: "The system could not find the file specified".

    Code:
    
    Sub ExecutePriorityBAT()Dim wshThisShell As WshShell
    Dim lngRet As Long
    Dim strShellCommand As String
    Dim strBatchPath As String
    Dim strShellSubCommand As String
    Set wshThisShell = New WshShell
    strShellSubCommand = "start  /high"
    strBatchPath = "C:\Program Files\Microsoft Office\Office14\Excel.exe"
    strShellCommand = """" & strShellSubCommand & strBatchPath & """"
    lngRet = wshThisShell.Run(strShellCommand, vbNormalFocus, vbTrue)
    End Sub
    
    
    Steve
     

Share This Page

Loading...