Discussion:
Uninstalling shell extension DLL without reboot.
(too old to reply)
KalliMan
2005-05-31 13:26:03 UTC
Permalink
Is it possible? I found many tutorials about Shell extensions, but each of
them requere restart when uninstall. Is it possible to uninstall and delete
my shell extension dll without restart? What do WinRar and WinZip? They
doesn't requere restart duaring the uninstall.

Thanks.
KalliMan
Dave Williss
2005-05-31 14:28:06 UTC
Permalink
Post by KalliMan
Is it possible? I found many tutorials about Shell extensions, but each of
them requere restart when uninstall. Is it possible to uninstall and delete
my shell extension dll without restart? What do WinRar and WinZip? They
doesn't requere restart duaring the uninstall.
Well, you don't need to restart the first time you install. To update
an NSE though, you have to make sure that nothing has loaded it
into memory, because you can't replace a file that's "in use".
That means closing Explorer (and apparently having to kill
it in my case - it doesn't seem to want to release my IShellFolder)
Also, if you have any program running which has brought up a file
selection dialog, you have to exit that too. I often have to close Visual
Studio in order to update my NSE.

If you install with InstallShield, I think there's a way to mark it so that
the installer puts it somewhere and then copies it to the right place the
next time you reboot. I'm not sure how though, because somebody else
in our company handles the installer issues.
Dave Townsend
2005-05-31 16:40:28 UTC
Permalink
Post by Dave Williss
Well, you don't need to restart the first time you install. To update
an NSE though, you have to make sure that nothing has loaded it
into memory, because you can't replace a file that's "in use".
That means closing Explorer (and apparently having to kill
it in my case - it doesn't seem to want to release my IShellFolder)
Also, if you have any program running which has brought up a file
selection dialog, you have to exit that too. I often have to close Visual
Studio in order to update my NSE.
It's quite a pain. Even a simple context menu handler still seems to get
held in memory, despite the reg setting that supposedly makes explorer
unload dlls. I was thinking of coming up with a kind of proxy dll, one
that explorer loads and uses, but really it in turn loads the real shell
extension from a second dll. Should be able to update the real dll much
more easily, though of course any update to the proxy would be just as
much of a pain.

Dave
Michael Phillips, Jr.
2005-05-31 17:15:57 UTC
Permalink
You can use the Task Manager to kill explorer.exe.
Then you can unregister the dll.

If you use visual studio and have it loaded, you can define a pre-build
event to
unregister the dll and run explorer.exe after you first killed explorer.

If not, you can use Task Manager to run a .cmd file which kills explorer,
unregisters the dll and
reloads explorer.exe
Post by Dave Townsend
Post by Dave Williss
Well, you don't need to restart the first time you install. To update
an NSE though, you have to make sure that nothing has loaded it
into memory, because you can't replace a file that's "in use".
That means closing Explorer (and apparently having to kill
it in my case - it doesn't seem to want to release my IShellFolder)
Also, if you have any program running which has brought up a file
selection dialog, you have to exit that too. I often have to close Visual
Studio in order to update my NSE.
It's quite a pain. Even a simple context menu handler still seems to get
held in memory, despite the reg setting that supposedly makes explorer
unload dlls. I was thinking of coming up with a kind of proxy dll, one
that explorer loads and uses, but really it in turn loads the real shell
extension from a second dll. Should be able to update the real dll much
more easily, though of course any update to the proxy would be just as
much of a pain.
Dave
KalliMan
2005-05-31 22:38:54 UTC
Permalink
10x Dave,

I want to uninstall my dll without InstallShield. Is it possible to force
Explorer to refresh the registry and free the unused dlls ?
Chuck Chopp
2005-06-01 12:27:56 UTC
Permalink
Post by KalliMan
10x Dave,
I want to uninstall my dll without InstallShield. Is it possible to force
Explorer to refresh the registry and free the unused dlls ?
Not reliably as far as I can tell. The Explorer shell wantonly latches on
to a shell extension DLL and keeps it in memory for periods of time that
seem unreasonably long when trying to replace the DLL. For testing
purposes, I just terminate the shell entirel by clicking "Start -> Shutdown"
and then hold down CTRL+ALT+SHIFT while clicking the "Cancel" button on the
shutdown dialog box. This causes the shell to exit, at which point you can
update the DLL from a command prompt window and then re-start the shell by
launching "explorer.exe" again. This works really well for a debug/test
environment.

If you need to simpy remove a shell extension, unregister it via REGSVR32 as
usual, or else remove the registry entries, make a call to SHChangeNotify()
to tell the shell to refresh itself and thus remove any NSE icons from under
"Desktop" and "My Computer", and then set up a delayed file rename/delete
that will happen at the next reboot to cause your shell extension DLL to be
removed from the system.
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

Do not send me unsolicited commercial email.
Dave Williss
2005-06-01 13:52:19 UTC
Permalink
Post by Chuck Chopp
Post by KalliMan
10x Dave,
I want to uninstall my dll without InstallShield. Is it possible to force
Explorer to refresh the registry and free the unused dlls ?
Not reliably as far as I can tell. The Explorer shell wantonly latches on
to a shell extension DLL and keeps it in memory for periods of time that
seem unreasonably long when trying to replace the DLL. For testing
purposes, I just terminate the shell entirel by clicking "Start ->
Shutdown" and then hold down CTRL+ALT+SHIFT while clicking the "Cancel"
button on the shutdown dialog box. This causes the shell to exit, at
which point you can update the DLL from a command prompt window and then
re-start the shell by launching "explorer.exe" again. This works really
well for a debug/test environment.
I find that CTRL+ALT+DELETE to bring up the Task Manager and then just
select and kill the EXPLORER.EXE process is a lot easier. I tend to leave
the task manager open while debugging the NSE, so I don't even have to
do that. Two clicks and it's gone.
KalliMan
2005-06-01 16:09:06 UTC
Permalink
10x to all,

But I don't want to debug. There is a simple way to debugging. Just Lunch
each explorer in separete process. I want to install ,uninstall or upgrate my
dll. And I thing there are no way to tell to explorer to free my dll. May be
the only way for upgrating is using a "proxy" dll. For uninstall IS wii
remove the dll after restart.

KalliMan.
Chuck Chopp
2005-06-01 17:16:07 UTC
Permalink
Post by KalliMan
10x to all,
But I don't want to debug. There is a simple way to debugging. Just Lunch
each explorer in separete process. I want to install ,uninstall or upgrate my
dll. And I thing there are no way to tell to explorer to free my dll. May be
the only way for upgrating is using a "proxy" dll. For uninstall IS wii
remove the dll after restart.
For all of the reasons mentioned earlier, a proxy DLL isn't an elegant
solution nor one that's likely to work well.

When a DLL is loaded in memory and the file is thus locked and cannot be
deleted or overwritten, then the only method typically available is to place
a copy of the updated DLL on the system, set up a delayed file
move/rename/copy operation and then reboot the system.
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

Do not send me unsolicited commercial email.
KalliMan
2005-06-01 19:46:10 UTC
Permalink
Yes, but too difficult and not comofrtable to our clients:(.

See Dave Townsend's Idea. There are 2 dlls. First the shell dll(locked dll)
which Implement Shell interfacess and redirect any to second dll. In
DllUnregisterServer in shell dll, I'll free the second dll, so it will be
able to replase it.
P.S. I thing WinZip use same technology.
Post by Chuck Chopp
Post by KalliMan
10x to all,
But I don't want to debug. There is a simple way to debugging. Just Lunch
each explorer in separete process. I want to install ,uninstall or upgrate my
dll. And I thing there are no way to tell to explorer to free my dll. May be
the only way for upgrating is using a "proxy" dll. For uninstall IS wii
remove the dll after restart.
For all of the reasons mentioned earlier, a proxy DLL isn't an elegant
solution nor one that's likely to work well.
When a DLL is loaded in memory and the file is thus locked and cannot be
deleted or overwritten, then the only method typically available is to place
a copy of the updated DLL on the system, set up a delayed file
move/rename/copy operation and then reboot the system.
--
Chuck Chopp
ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com
RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651
Do not send me unsolicited commercial email.
Dave Williss
2005-06-01 21:29:24 UTC
Permalink
I don't think that would work.

I assume that you have DllUnregisterServer call FreeLibrary on
the "real" dll. The problem is that Explorer may still have pointers
to your interfaces, and the virtual function tables for those will be
pointing to code which you've just freed. So if Explorer tries to
update anything, you're toast.

However... If you have DllUnregisterServer call your
DllCanUnloadNow and only Free the real dll in that case, you
should be OK. You just have to know to reload and
GetProcAddress the main functions again before calling them.

Hmmmm.... I'll have to try this.
Post by KalliMan
Yes, but too difficult and not comofrtable to our clients:(.
See Dave Townsend's Idea. There are 2 dlls. First the shell dll(locked dll)
which Implement Shell interfacess and redirect any to second dll. In
DllUnregisterServer in shell dll, I'll free the second dll, so it will be
able to replase it.
P.S. I thing WinZip use same technology.
Post by Chuck Chopp
Post by KalliMan
10x to all,
But I don't want to debug. There is a simple way to debugging. Just Lunch
each explorer in separete process. I want to install ,uninstall or upgrate my
dll. And I thing there are no way to tell to explorer to free my dll. May be
the only way for upgrating is using a "proxy" dll. For uninstall IS wii
remove the dll after restart.
For all of the reasons mentioned earlier, a proxy DLL isn't an elegant
solution nor one that's likely to work well.
When a DLL is loaded in memory and the file is thus locked and cannot be
deleted or overwritten, then the only method typically available is to place
a copy of the updated DLL on the system, set up a delayed file
move/rename/copy operation and then reboot the system.
--
Chuck Chopp
ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com
RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651
Do not send me unsolicited commercial email.
KalliMan
2005-06-02 14:34:04 UTC
Permalink
Dave,
In My case it seems to work. Do u try it?
Post by Dave Williss
I don't think that would work.
I assume that you have DllUnregisterServer call FreeLibrary on
the "real" dll. The problem is that Explorer may still have pointers
to your interfaces, and the virtual function tables for those will be
pointing to code which you've just freed. So if Explorer tries to
update anything, you're toast.
However... If you have DllUnregisterServer call your
DllCanUnloadNow and only Free the real dll in that case, you
should be OK. You just have to know to reload and
GetProcAddress the main functions again before calling them.
Hmmmm.... I'll have to try this.
Post by KalliMan
Yes, but too difficult and not comofrtable to our clients:(.
See Dave Townsend's Idea. There are 2 dlls. First the shell dll(locked dll)
which Implement Shell interfacess and redirect any to second dll. In
DllUnregisterServer in shell dll, I'll free the second dll, so it will be
able to replase it.
P.S. I thing WinZip use same technology.
Post by Chuck Chopp
Post by KalliMan
10x to all,
But I don't want to debug. There is a simple way to debugging. Just Lunch
each explorer in separete process. I want to install ,uninstall or upgrate my
dll. And I thing there are no way to tell to explorer to free my dll. May be
the only way for upgrating is using a "proxy" dll. For uninstall IS wii
remove the dll after restart.
For all of the reasons mentioned earlier, a proxy DLL isn't an elegant
solution nor one that's likely to work well.
When a DLL is loaded in memory and the file is thus locked and cannot be
deleted or overwritten, then the only method typically available is to place
a copy of the updated DLL on the system, set up a delayed file
move/rename/copy operation and then reboot the system.
--
Chuck Chopp
ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com
RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651
Do not send me unsolicited commercial email.
Matt Ellis
2005-06-03 08:59:00 UTC
Permalink
Having a file1.dll and file2.dll would be one way to go. If one is
locked, install the other, and point all your clsid's to the new one.
Then, in your DllMain (maybe) of the new one try and delete the old
one.

Cheers
Matt

Chuck Chopp
2005-06-01 17:20:25 UTC
Permalink
Post by KalliMan
But I don't want to debug. There is a simple way to debugging. Just Lunch
each explorer in separete process.
I got "burned" really bad with debugging NSE's in separate processes like
that. Since the normal operating environment for the shell is to run a
single process, debugging with a NSE running in separate processes can mask
certain problems due to the difference in the run-time & debug environments.
I've found that cleanly terminating the shell process and then having the
debugger launch explorer.exe as its debug target program to be a very
reliable method to use.
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

Do not send me unsolicited commercial email.
Chuck Chopp
2005-06-01 17:18:10 UTC
Permalink
Post by Dave Williss
I find that CTRL+ALT+DELETE to bring up the Task Manager and then just
select and kill the EXPLORER.EXE process is a lot easier. I tend to leave
the task manager open while debugging the NSE, so I don't even have to
do that. Two clicks and it's gone.
Yes and no... If the shell instance of explorer.exe voluntarily terminates,
it doesn't automatically re-spawn. However, if it dies due to an unhandled
exception or if it gets killed, on Win2K & newer, I find that it
automatically gets re-spawned.

I tend the leave both the task manager and a command prompt window open
during debugging. I grew up in a command line environment and just find it
way too convenient in terms of functtionality to give up.
--
Chuck Chopp

ChuckChopp (at) rtfmcsi (dot) com http://www.rtfmcsi.com

RTFM Consulting Services Inc. 864 801 2795 voice & voicemail
103 Autumn Hill Road 864 801 2774 fax
Greer, SC 29651

Do not send me unsolicited commercial email.
KalliMan
2005-05-31 23:07:16 UTC
Permalink
10x Dave,

I want to uninstall my dll without InstallShield.
Is it possible to force Explorer to refresh the registry and free the unused
dlls ?
Miles Ahead
2005-06-02 19:57:09 UTC
Permalink
On Tue, 31 May 2005 16:07:16 -0700, "KalliMan"
Post by KalliMan
10x Dave,
I want to uninstall my dll without InstallShield.
Is it possible to force Explorer to refresh the registry and free the unused
dlls ?
You can try this freeware shell extension and see if it helps. It's
designed to go around closing all the handles open on the selected
file, "unlocking" it:

http://ccollomb.free.fr/unlocker/

I have it running on my system and it doesn't seem to hurt anything.
So far I haven't gotten a "file is in use" dialog to try it though. :)
Loading...