Sign in to follow this  
Followers 0
TheMailman

ProcessSetPriority

6 posts in this topic

#1 ·  Posted (edited)

Helloes to all people in the forum,been lurking the forum for a while, first time posting, and I humbly ask This great community for help on a small tiny hiccup :

ProcessSetPriority fails to set the desired priority on the target exe while the following conditions are true:

There are multiple instances of target exe, from different directories (ie. C:\1\client.exe adn C:\2\client.exe are both running)

All of those target exe files are run under different accounts (ie. C:\1\client.exe runs on account "LoL" and C:\2\client.exe is running on account "Fail")

I tried the example script which comes with autoit (latest at the time of posting), and it worked fine. (that script about notepad.exe)

ProcessSetPriority ("winamp.exe",1) work fine too (tho thats quite stupid to set it low, made sure the ProcessSetPriority works)

but my script fails:

;;-- script begin -- ;;

runasset ("LoL","","PaSS")

$jee = ProcessSetPriority("client.exe", 0)

msgbox (1,"jee",$jee)

runasset ("Fail","","WoRD")

$jee = ProcessSetPriority("client.exe", 0)

msgbox (1,"jee",$jee)

;;-- script end -- ;;

both msg boxes return 0 :S

and currently i am running 4 of those exe files

any suggestions?

quickie edit : what i am trying to accomplish with the help of this script is faster launching times for the target applications, sometimes i run only 2 of them and its not big deal, sometimes i run up to 30, and reducing the priority of the ones that have already been launched down to idle would boost the startup of the next one radically (atleast when the 11th+ launches)

Edited by TheMailman

Share this post


Link to post
Share on other sites



Helloes to all people in the forum,been lurking the forum for a while, first time posting, and I humbly ask This great community for help on a small tiny hiccup :

ProcessSetPriority fails to set the desired priority on the target exe while the following conditions are true:

There are multiple instances of target exe, from different directories (ie. C:\1\client.exe adn C:\2\client.exe are both running)

All of those target exe files are run under different accounts (ie. C:\1\client.exe runs on account "LoL" and C:\2\client.exe is running on account "Fail")

I tried the example script which comes with autoit (latest at the time of posting), and it worked fine. (that script about notepad.exe)

ProcessSetPriority ("winamp.exe",1) work fine too (tho thats quite stupid to set it low, made sure the ProcessSetPriority works)

but my script fails:

;;-- script begin -- ;;

runasset ("LoL","","PaSS")

$jee = ProcessSetPriority("client.exe", 0)

msgbox (1,"jee",$jee)

runasset ("Fail","","WoRD")

$jee = ProcessSetPriority("client.exe", 0)

msgbox (1,"jee",$jee)

;;-- script end -- ;;

both msg boxes return 0 :S

and currently i am running 4 of those exe files

any suggestions?

Try getting the PID of each instance and use that to set the priority.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

i keep on failing, but thanks for the idea! (think i tried it yesterday while being half asleep)

runasset ("LoL","","PaSS")

$PID = WinGetProcess ("ClientWindow1")

msgbox(1,"jee",$PID)

$jee = ProcessSetPriority($PID, 2)

msgbox (1,"jee",$jee)

ps. the same exe files DO have different title names, so if that would have worked, it would have been splendid, alas, i failed atleast

(atleast the wingetprocess got it right)

Share this post


Link to post
Share on other sites

cant figure out any other ways, using PID or exe full path doesnt seem to work either :< any random ideas would be greatly appereciated

Share this post


Link to post
Share on other sites

cant figure out any other ways, using PID or exe full path doesnt seem to work either :< any random ideas would be greatly appereciated

See if this works for you. Might need more thorough testing - for each instance of the program executed, it grabs the last element in the ProcessList array for the PID. With this example, you can change the priority of any individual instance of the program.

#include <Process.au3>
#include <GUIConstants.au3>
#include <Array.au3>

Dim $guiwidth = 200, $guiheight = 100
Dim $PIDrecords

$myGUI = GUICreate("Test Priority", $guiwidth, $guiheight, -1, -1, $WS_overlappedwindow)

$PriorityInput = GUICtrlCreateInput("", 80, 10, 35, 20)
GUICtrlSetData(-1, 2)
$PriorityUpDown = GUICtrlCreateUpdown($PriorityInput)
GUICtrlSetLimit(-1, 5, 0)
GUICtrlSetTip(-1, "Click the Set button to reset the execution priority to selected value")
GUICtrlSetResizing($PriorityInput, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT+$GUI_DOCKWIDTH)

$priorityLabel = GUICtrlCreateLabel("Priority:  "  , 130, 12, 70, 15)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT+$GUI_DOCKWIDTH)
GUICtrlSetTip($priorityLabel, "Process priority - Actual")

$prioritySetButton = GUICtrlCreateButton("Set", 40, 10, 30, 17)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT+$GUI_DOCKWIDTH)
GUICtrlSetTip($prioritySetButton, "Click to set execution priority to selected value.")

$priorityOptionButton = GUICtrlCreateButton("? ", 26, 10, 12, 17)
GUICtrlSetTip($priorityOptionButton, "Click for execution priority options")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKHEIGHT+$GUI_DOCKWIDTH)

$PIDDisplayLabel = GUICtrlCreateLabel("PID", 26, 40, 40, 17)
$PIDDisplay = GUICtrlCreateLabel("", 56, 40, 40, 17)


GUISetState() ; show form

$PIDList = ProcessList("_Priority.exe")
;_ArrayDisplay($PIDList)
;MsgBox(0, "PID", $PIDList[$PIDList[0][0]][1])
$PID = $PIDList[$PIDList[0][0]][1]
GUICtrlSetData($PIDDisplay, $PID)
GUICtrlSetData($priorityLabel,"Priority: " & _ProcessGetPriority($PID))


While 1
    
    $msg = GUIGetMsg()
    

    Switch $msg

        Case $GUI_EVENT_CLOSE
            Exit
        

        Case $PriorityInput
            GUICtrlSetData($priorityLabel, "Priority:  " & _ProcessGetPriority($PID))
            
        Case $prioritySetButton
            $DesiredPriority = GUICtrlRead($PriorityInput)
            If $DesiredPriority = 5 Then $response = MsgBox(1, "Are you sure?", "Setting run priority to 5 (realtime) may make " & @CR & _
                "the system unstable. Are you sure?")
            If $DesiredPriority < 5 Or $response = 1 Then ProcessSetPriority($PID, $DesiredPriority)
            GUICtrlSetData($priorityLabel, "Priority:  " & _ProcessGetPriority($PID))
                    
        Case $priorityOptionButton
            MsgBox(0, "Priority Options", "0 - Idle/Low" & @CR & _
                "1 - Below Normal (Not supported on Windows 95/98/ME)" & @CR & _
                "2 - Normal" & @CR & _
                "3 - Above Normal (Not supported on Windows 95/98/ME)" & @CR & _
                "4 - High" & @CR & _
                "5 - Realtime (Use with caution, may make the system unstable)")

    EndSwitch

WEnd

_Priority.au3

Share this post


Link to post
Share on other sites

charming, it manages to change the priority of the exe, but only when i run this program under the same user account (but that can be automated too).

gonna be a huge fuss to write the launch again with this one innit :) but thanks for this GREAT tool! really really really appereciated

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0