Old 19th April 2004, 16:57   #1
tommy916
Junior Member
 
Join Date: Apr 2004
Posts: 19
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
tommy916 is offline   Reply With Quote
Old 19th April 2004, 17:08   #2
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
The whole Windows desktop is based on explorer, that isn't something you should close.
Joost Verburg is offline   Reply With Quote
Old 19th April 2004, 18:15   #3
tommy916
Junior Member
 
Join Date: Apr 2004
Posts: 19
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...
tommy916 is offline   Reply With Quote
Old 19th April 2004, 18:24   #4
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
You'll have to use /REBOOTOK and let the user reboot the computer.
Joost Verburg is offline   Reply With Quote
Old 21st April 2004, 04:17   #5
keitsi
Junior Member
 
Join Date: Apr 2004
Location: Finland
Posts: 4
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.

code:

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

keitsi is offline   Reply With Quote
Old 21st April 2004, 05:19   #6
keitsi
Junior Member
 
Join Date: Apr 2004
Location: Finland
Posts: 4
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
keitsi is offline   Reply With Quote
Old 21st April 2004, 08:35   #7
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
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.
Joost Verburg is offline   Reply With Quote
Old 22nd April 2004, 02:16   #8
keitsi
Junior Member
 
Join Date: Apr 2004
Location: Finland
Posts: 4
vb6

Quote:
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.

Quote:
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
keitsi is offline   Reply With Quote
Old 22nd April 2004, 09:25   #9
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
NSIS has a FindWindow and SendMessage command.
Joost Verburg is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump