Processes on Windows, you can set priorities, such as
So, what if we need to prioritize processes in our automated testing process?
The following is the implementation of this function using the Win32 related interfaces, as follows:
# Gets the user handle htoken = win32security. OpenProcessToken (Win32API. GetCurrentProcess (), Win32con. Token_duplicate | Win32con. Token_adjust_default |win32con. Token_query | Win32con. token_assign_primary) hNewToken = Htoken authority = 0x0002000 if securitylevel! = "": AUT hority = 0x0002000 if securitylevel.lower () = = "Low": authority = 0x0001000 hNewToken = Win32 Security. Duplicatetokenex (Htoken, win32security. Securityimpersonation, 0, win32security. Tokenprimary, None) # build SID sid = Win32security for the corresponding level. SID () Sid. Initialize ((0, 0, 0, 0, 0, +), 1) SID. Setsubauthority (0, authority) # Sets the SID to the user handle win32security. Settokeninformation (hNewToken, win32security. Tokenintegritylevel, (SID, Win32security.se_group_integrity)) CommandLine = Procpath + "" + param # Launcher Si = win32process. Startupinfo () win32process. CreateProcessAsUser (hnewToken, None, CommandLine, none, none, False, 0, none, none, Si)
In this way, we can start the corresponding process using different priority ~ ~
Reprint Please specify: Http://blog.csdn.net/sogouauto
Explore test art, Exchange test technology, Welcome to the "Sogou test"
Python writes automation to start a process at different priority levels