Archive: some troubles


some troubles
Hi !
There are some troubles I can't solve and it took me lots of headaches... :igor:
I've created an installation package (w/ modern UI :D : I had to remove components page and it was one more headache !) for a software which put an icon in the systray.
1. The install puts only links in the start menu of the logged user. I have put an uninstall shorcut available throught "Add/Remove Software" of Control Panel so it can be unsinstalled from ANY user session... If I uninstall from an other user session than those which was used to install it, the shortcuts are kept (but broken)... How to be sure to remove ALL shortcuts for all users (or just these of the user which was used to install) ?
2. The software uses a .dll file. If the software runs when uninstall is started, uninstall close it (Findwindow + SendMessage 16) but I don't know why .dll isn't deleted and so the INSTDIR stays (if the software aren't running it works fine). How to be sure the .dll file will be deleted ? (Note that if is a .txt file which the software read, it's the same thing : the .txt isn't remove)
A bonus question : What's the best way to close a software which have only an icon in the systray ?
Regards


1) Use SetShellVarContext all before you create the shortcuts to make sure they will be created for all of the users, and then they could be easily deleted for all users.
2) Make sure the software closes all handles it has, and then you will be able to delete those files.
3) Find the window that controls the system tray icon and send it a ${WM_CLOSE} (defined in ${NSISDIR}\Examples\WinMessages.NSH).


Waow ! Very quick answer ! Thx.
1. In fact I prefer the shortcuts to be installed only for current user, so what the solution ?
2. All handles. I'm not sure it has a lot... And how to know which one it uses and how to close them ?
3. Already done and it works (the only thing that does:)), so it seems to be the only solution... But I use SendMessage 16 0 0 (No need to include one more file)


1) Either let the user that installed uninstall, or save the location of the shortcuts somehow (the registry maybe), restore that location in the uninstaller and use it to delete them.
2) Did you write the software? If not, it may be possible to use Sleep to make this work. Give it time to lose the locks on the files.
3) Best solution AFAIK.


1. Hum, regisry seems to be fine, as I still put a key so that the uninstall could be run from control panel
2. I didn't write the sofware, I've translated into french and it's author is nowhere to be found. I still use Sleep and I don't know why but w/ alpha 7 final (08/28/02) it works : the .dll file is deleted even if the software must be closed by NSIS (is was the cas w/ a prerelease I used) !
3. Ok, thx. (how to find the classname of a software which is in the systray ?)
CU and thx (How could you be so quick ? Do you have 2 heads or 4 arms ?)


I have thought a bit and I think I have found a solution (it may not be the best but it is a soluton) :
Why not write a function which browse for every start menu folders and then delete the same item in all (delete in default user and in folders of each profiles Window directory) ?
Trouble is that I need to use Push and Pop and I can't figure out how to use them, maybe do you have an idea on how I could write this function ?


Personally, I think that creating the shortcuts in the "all users" start menu is the best solution, but if you insist... I remember I have seen such a function once in the forums. I couldn't find it, maybe you will have better luck.

Push and Pop are stack functions. Stack works by the LIFO method. LIFO means First In Last Out. That means that if you Push two things and then Pop two things you will get them in the oppsite order.

It is always useful to make a drawing out of a stack:

After two pushes:


-------------
| Second |
-------------
| First |
------------------


One pop later:

-------------
| First |
------------------


I hope that helps :D

That's still a bit confused..
I don't understand why SetShellVar all works but if current is specified, NSIS doesn't remember which one was used...
Drawing the state of the stack is an idea...
I hoped you could help me in writing this scan code but if I can't found it in the forum then I will try...
I will do a scan which put on the stack each Profiles folder it founds... Then reading from the stack, I will remove (hope I will succeed in doing that, not sure :( )
CU


A stack is a very simple idea. The stack starts empty. You push things onto it one at a time and the stack grows. This is like adding plates to a stack of plates. When you "pop" one it means you take the top plate from the stack (which was the last one you "pushed" onto the stack).

Push 'A' -- stack now contains one item, 'A'
Push 'B' -- stack now contains two items, 'A' on the bottom with 'B' stacked on top of it
Push 'C' -- stack now contains three items, 'A' at the bottom, 'B' above 'A', and 'C' above 'B'.

When you pop you remove the items in the reverse order that you pushed them so...

Pop $0 -- takes 'C' off the stack and places it into $0
Pop $1 -- takes 'B' off the stack
Pop $2 -- takes 'C' off the stack

The stack is now empty again.


I don't understand why SetShellVar all works but if current is specified, NSIS doesn't remember which one was used...
Current user means the current user for good or bad. NSIS doesn't remember anything from the installer in the uninstaller, unless you make it (regisrty, files, or INI).

Ok, I have wrote 2 functions in order the uninstall remembers where items was installed (As I still use a part of the registry to make the uninstall available from control panel I knew where to put extra infos)...
Uninstall is a little buggy but I can't figure out why. Here they are (I didn't sleep a lot last night :igor: )

[edited by kichik, please attach large script next time]
File attached below :down:


Hum, I am very tired... I have to pass less time on NSIS coding :eek:
I have downloaded latest version of makensis* from CVS, I will try if it works w/ them...
Can you check the 2 functions and give me some feedbacks (improvements or other) ?
CU


I think I see the problem. In the following line you should replace DeleteRegKey with DeleteRegValue

DeleteRegKey HKLM \ 
"Software\Microsoft\Windows\CurrentVersion\Uninstall\PushPin" \
"StartMenuProgramsPath$1"

I don't think this should have compiled as it stood, as DeleteRegKey should only take two full parameters (plus the optional "/ifempty" flag). I shall look into it. If it did compile (as it seems) then the third parameter must have been ignored resulting in the whole key being deleted.

Hope that solves it for you...

[edit] Confirmed this to be a bug, which I've just fixed. Once a new makensis.exe is uploaded, it should (correctly) refuse to compile your original function, until the first DeleteRegKey is changed to DeleteRegValue.

Nice catch eccles, a bug that potentially deletes an entire key is nasty indeed!


Script attached here.

Recompiled version check in the CVS.


It's for that it didn't work : the reg key were deleted when reading first entry and following couldn't be deleted (logical)...
I took me hours and hours to write this 2 functions (I couldn't figure out how to create a scan scode w/ NSIS commands) and I didn't use the good command, I need also to buy eyes :eek:
Thx to have pointed out this...
Two more things :
* This new makensis version require NLF v2 header, I got an error "bad language file version" (normal I think)
* I can't figure out why justin "Refresh uninstall panel" function (that I found on the Sunjummer site) doesn't work - reproduced here (not large kichick) :
Function un.RefreshUninstallPanel
Push $0
Push $1
StrCpy $1 ""
again:
FindWindow $0 "#32770" "Propriétés de Ajout/Suppression de programmes" ;French system (english one is "Add/Remove properties")
StrCmp $0 0 done
SendMessage $0 ${WM_CLOSE} 0 0
StrCpy $1 1
goto again
done:
StrCmp $1 "" noopen
Exec '"$WINDIR\control.exe" appwiz.cpl'
noopen:
Pop $1
Pop $0
FunctionEnd

The window is closed but not opened again... What's the matter ? (I tried to run the command from Execute of the Star Menu and it works)
Regards (After that I think I have finished...)


This post only to attach the good version of the 2 functions...
I think there are great and they can be distributed.
Feedback is welcome !


* This new makensis version require NLF v2 header, I got an error "bad language file version" (normal I think)
New NLFs are uploaded everyday. Currently only the Swedish NLFv2 is missing. Go to the CVS and get the latest NLF for your language.