It is currently April 23rd, 2024, 2:01 pm

[BUG?] UsageMonitor PID-s for Google Chrome

Report bugs with the Rainmeter application and suggest features.
User avatar
Yincognito
Rainmeter Sage
Posts: 7149
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[BUG?] UsageMonitor PID-s for Google Chrome

Post by Yincognito »

I have a similar process to the one below in one of my skins:

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[KillTopProcessID]
Measure=Plugin
Plugin=RunCommand
Parameter=taskkill /F /PID [TopProcessID:]
State=Hide
OutputType=ANSI
Timeout=5000
DynamicVariables=1

[TopProcessName]
Measure=Plugin
Plugin=UsageMonitor
Alias=CPU
Index=1
Rollup=0
DynamicVariables=1

[TopProcessValue]
Measure=Calc
Formula=TopProcessName

[TopProcessID]
Measure=Plugin
Plugin=UsageMonitor
Category=Process
Counter=ID Process
Name=[TopProcessName]
DynamicVariables=1

---Meters---

[TopProcess]
Meter=String
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
AntiAlias=1
Text="Name = [TopProcessName]#CRLF#CPU  = [TopProcessValue:2]#CRLF#PID  = [TopProcessID:]#CRLF##CRLF#MClick Kill"
MiddleMouseUpAction=[!UpdateMeasure KillTopProcessID][!CommandMeasure KillTopProcessID "Run"]
DynamicVariables=1
The idea is to kill the "misbehaving" top processes (CompatTelRunner, SoftwareReporterTool, etc.) on middle click. I had to use the PID approach since bare process name wouldn't yield the extension required by the /IM taskkill parameter. Now, that works well, except the PID for Chrome instances are way off, compared to what's reported in Windows' PerfMon.msc (either 0 or 6 digit PID instead 4 digit one like reported by PerfMon.msc in the 2nd row from the screenshot below):
4 digit PID.jpg
6 digit PID.jpg
0 PID.jpg
P.S. This goes for non-indexed instances of Chrome, i.e. bare chrome process name.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7149
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [BUG?] UsageMonitor PID-s for Google Chrome

Post by Yincognito »

For the record, I managed to use a more effective method to kill the top process (this, although slower, will work where the above one failed, since it's executed with administrative privileges and doesn't need the process extension nor the PID in this approach):

Code: Select all

[Variables]

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[KillTopProcessID]
Measure=Plugin
Plugin=RunCommand
Program=powershell
Parameter=Start-Process powershell -windowstyle Hidden -verb RunAs \"Stop-Process -Name '[&TopProcessName]' -Force; Exit\"
State=Hide
OutputType=ANSI
Timeout=5000
DynamicVariables=1

[TopProcessName]
Measure=Plugin
Plugin=UsageMonitor
Alias=CPU
Index=1
DynamicVariables=1

[TopProcessValue]
Measure=Calc
Formula=TopProcessName

---Meters---

[TopProcess]
Meter=String
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
AntiAlias=1
Text="Name = [TopProcessName]#CRLF#CPU  = [TopProcessValue:2]#CRLF##CRLF#MClick Kill"
MiddleMouseUpAction=[!CommandMeasure KillTopProcessID "Run"]
DynamicVariables=1
but I still think the above PID issues are a bug and I'm interested in what you think it can be done to fix it.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth