views:

90

answers:

3

I created a windows explorer toolbar in C#. This toolbar is removed when uninstalling my applicaiton but it's still shown after unregistering (cached in explorer.exe). explorer.exe needs a restart in order toolbar to dissapear. How can I fix this by C# code?

A: 
foreach(Process p in Process.GetProcesses()){

try{

if(p.MainModule.ModuleName.Contains("explorer") == true)p.Kill();

}
catch(Exception e){}

Process.Start("explorer.exe");

}

Give that a go.

Dremation
This is not a good solution because restarting explorer.exe will close all user windows. I want a refresh not a restart.
Cornel
You specifically said "explorer.exe needs a restart in order to dissapear", so I gave you code to restart it. Please be more clear with your question before you down point the answer.
Dremation
I think you did not understand correctly the title of the question. The toolbar to dissapear not explorer.exe. Please read more carefuly the question before posting an answer.
Cornel
Regardless, Dremation, your solution is flawed: you'd kill "GameExplorer.exe" and "ProcessExplorer.exe" and "ArentExplorersGreat.exe" too. On top of that, you're ignoring all exceptions (horrendous practise), and your scope is in the wrong place, so you'd actually start a new instance of explorer for *every process* on the user's machine. Bad answer!
Dan Puzey
-1 Definitely a bad idea.
statenjason
A: 

I'm not sure that explorer would cache the toolbar if it's been properly unloaded. I know little about these things, but are you sure you're not missing a deregistration call in your installer?

Dan Puzey
+1  A: 

There is really no way to do this cleanly without asking the user to log off.

If there is programatic access to turn off your toolbar, you could inject some code into every explorer process that has your dll loaded and turn off the toolbar and then call CoFreeUnusedLibraries (Still somewhat hacky but you would not have to kill processes)

Anders