Archive: close windows Explorer


close windows Explorer
How do I close all the Windows Explorer on init?

I looked at this link but it's for IE browser. http://nsis.sourceforge.net/archive/...instances=0,11


The whole Windows desktop is based on explorer, that isn't something you should close.


ok i guess i have to find other way.

How do you ignore the error and then go to the next line. This is to put the file blah.dll into the folder but the dll is currently used which is in the Windows Explorer. since i can't close the explorer.

Error opening file for writing: "C:\blah\blah.dll"
Hit abore to abort installation, retry, ignore...


You'll have to use /REBOOTOK and let the user reboot the computer.


I would write a VB6 .exe, and use the FindFindow and SendMessage APIs.
(first, find a explorer window based on name with findwindow. then send the window a WM_CLOSE integer)
I've used this with VB6, but those APIs are available to other languages as well.

Hmm, after a second thought you can't find the windows based on window titles since it may be the folder name as well :)
Well you could look into some windows APIs and write an exe to be included in the installer to do the job.

EDIT: VB6 code that could work. You could find the open windows based on classname, instead of title.


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub

wcloser.exe
Here, it just seemed too easy :P

You may use it from command line, i.e. run:
wcloser.exe ExploreWClass
.. to close all explorer windows. Also has a GUI to test it.

http://lappi.skai.fi/~mikkoko/vbmodu...ndowCloser.zip


First of all explorer.exe should not be closed because it is the whole Windows desktop. It also doesn't have a window title.

The same thing can also be done using NSIS script code without VB6. When using a VB6 executable your installer will have to include the VB6 runtimes, which is a bit overkill for such a simple thing.


vb6

First of all explorer.exe should not be closed because it is the whole Windows desktop.
true dat, it's annoying when you lose all the systray icons.

The same thing can also be done using NSIS script code without VB6. When using a VB6 executable your installer will have to include the VB6 runtimes, which is a bit overkill for such a simple thing.
I have no idea how I should do with nsis, and with vb it took like 5 minutes.

I'm using nsis mostly for vb6 installers so the runtimes for wcloser aren't a big problem since the runtimes are already installed when I run it :P

NSIS has a FindWindow and SendMessage command.