I need a list of names (keys) of Windows services. Windows 10 introduced a concept of per-user services that creates new service instances with LUID (Locally Unique IDs) attached to their names. I need to ignore these instances, but resulting list should contain templates for them.
For example if there is running service ContactData_443f50
I need to have ContactData
listed in output (without LUID and duplication for multiple users logged in)
I've already used WMI query select * from Win32_Service
to look up service names, but the list contains instances of per-user services and does not contain templates for them.
I've also run sc.exe queryex
- this list provided me with per-user services clearly marked as such. I would need to parse the output through, and I am not sure about potential localization or future-proof of that solution
I would prefer using WMI for the task.
win32_service does not return "per-user services" information. Personally, I would look for it in the registry. E.g : HKLM \ SYSTEM \ CurrentControlSet \ Services \ WpnUserService_3ce1a (REG_DWORD) Type: 224 HKLM \ SYSTEM \ CurrentControlSet \ Services \ WpnUserService (REG_DWORD) Type: 96
"per-user services" is always 224.