How can I increment Windows Performance Counters from Python 3.7?

I have a Python script running on Python 3.7 and I would like to increment, decrement, or otherwise write to Windows Performance Monitor Counters as used by Perfmon.exe. I found a module called win32pdh that appears to be part of pywin32. My understanding of Python's module system is limited. These pages have information that seems to only relate to querying the counters. Can anyone see if this is intended to also update them or is there another preferred way to go about this?

https://www.cac.cornell.edu/wiki/index.php?title=Performance_Data_Helper_in_Python_with_win32pdh

http://timgolden.me.uk/pywin32-docs/win32pdh.html


Althought the documentation does not say it explicitly, counters are read-only. You can create a counter to write to it, or read from an existing counter, but you can't write to counters you do not own.

There is list of performance counters usages but writing into system counters is not one of them. That's why the Python documentation you found mostly talks about querying them. Even publishing a new counters set is not a common task, and may not be supported by these Python libraries (I did not checked). For more info about counter creation, see this page.