[quote quote=133938]Thank for the prompt response Logan. I don’t know too much about WMI Event Consumers, but persistence is certainly desired. I’m basically trying to achieve a persistent script that will change wallpapers depending on screen resolution. Is there an equivalent WMI class I can query to listen for this type of event ie) when display settings are changed?
I am still learning about WMI consumers, there is not a lot of well documented stuff on the interwebs. Mostly the same couple of examples for monitoring a directory for changes to filenames, or formatting a USB drive upon insertion. I have a couple of solutions I have crafted for my own purposes and to learn more about the concepts. I have learned a lot and plan on writing a couple of blog posts on the topic and sharing my original examples based on methodology adapted by Ed Wilson, Boe Prox, and Trevor Sullivan on their blog posts. Its a VERY in-depth topic and I don’t have time to dive into all of it. I will share with you the starting point for it all, a working WQL query.
$query = “SELECT * FROM __InstanceModificationEvent WITHIN .1 WHERE TargetInstance ISA ‘Win32_VideoController’”
You can use wbemtest.exe to test queries and examine TargetInstance objects in depth. I will also share some of the blogs I have used as a jumping off point to develop my solutions.
CodeProject (Good examples of consumers in MOF format)
Boe Prox Blog on WMI Consumers
A word of caution… These bindings are PERMENANT and require explicit removal from WMI or a re-image of the box to get rid of. If you are not paying close attention, or are not completely comfortable with finding and removing bindings in WMI be careful! Pay attention to what you are doing and make sure you are on a DEV box.