title: How can I get win32pdhutil to query a performance counter with a slash?
body: <p>I'm trying to query Windows Performance Counters using <strong>win32pdhutil</strong> from the pywin32 package in Python, but I run into an error whenever the counter name has a slash.</p>
  
  <p>For example, this code works fine:</p>
  
  <pre><code>import win32pdhutil
  
  query = win32pdhutil.GetPerformanceAttributes("Memory", "Available Bytes")
  </code></pre>
  
  <p>But this code fails:</p>
  
  <pre><code>import win32pdhutil
  
  query = win32pdhutil.GetPerformanceAttributes("Memory", "Cache Faults/sec")
  </code></pre>
  
  <p>The error message is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;path&gt;\Python\Python38-32\lib\site-packages\win32\lib\win32pdhutil.py", line 61, in GetPerformanceAttributes
      type, val = win32pdh.GetFormattedCounterValue(hc, format)
  pywintypes.error: (-1073738810, 'GetFormattedCounterValue', 'The data is not valid.')
  </code></pre>
  
  <p>I've tried a number of different counters and only run into this issue when there is a slash in the counter name.</p>
  
  <p>My original code uses win32pdh.AddCounter and win32pdh.CollectQueryData with the same issue, but the example above demonstrates it in a single line.  </p>
  
  <p>I found a similar thread <a href="https://mail.python.org/pipermail/python-win32/2011-March/011382.html" rel="nofollow noreferrer">here</a>, without an obvious solution.</p>