Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a weird problem where something is changing my path in my login session. The permanent path in the registry is not changing.

I wanted to monitor changes to the explorer.exe process's environment variables using Register-CimIndicationEvent with the Win32_Process CIM object. However, I don't see anything about environment variables there. Is there a property I am missing? Is there another way to get the current environment for another process, and track changes to it?

There is a Win32_Environment class. However, it reads from the registry tags where environment variables are stored. It doesn't read the working variables.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I the environment is not something that is available easily through any API or through WMI.

The simplest route to track your environment would be to make regular checks through Process Explorer to see when the change is happening.

If you can handle writing a bit of C++ code here are a couple of resource on how to access another process' environment. You could use that to create a tool to monitor the environment for you:

share|improve this answer
1  
Hrm, well I'd prefer to just use PInvoke rather than C++, for the same effect. I shall give it a try. –  Justin Dearing Sep 24 '12 at 20:49
    
@JustinDearing: +1 for C#. –  surfasb Sep 26 '12 at 0:17
    
Systernals ProcessExplorer works great for spying on the current environment variables. –  John Dyer Jun 11 at 14:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.