- NSIS Discussion
- Delete shortcuts in start menu
Archive: Delete shortcuts in start menu
Cherry17
31st October 2005 23:03 UTC
Delete shortcuts in start menu
Hello,
I have got a problem with deleting the shortcuts in the start menu while uninstalling the program. I have read the posts in the forum but I did not find a solution.
I write the shortcuts with:
Var /GLOBAL test
StrCpy $R1 $R0 1
StrCpy $test $R0
StrCmp $R1 ">" skip
SetShellVarContext all
CreateDirectory $SMPROGRAMS\$R0
CreateShortCut $SMPROGRAMS\$R0\Analyzer.lnk $INSTDIR\Analyzer.exe
CreateShortCut $SMPROGRAMS\$R0\Uninstaller.lnk $INSTDIR\Uninstaller.exe
skip:
I want to delete them with:
Delete "$SMPROGRAMS\$test\*.*"
RMDir "$SMPROGRAMS\$test"
It does not work.
If I use
Delete "$SMPROGRAMS\Analyzer 1.0\*.*"
RMDir "$SMPROGRAMS\Analyzer 1.0"
it works. But I will not know the folder the user will choose so my second solution is not great. What's wrong with the first solution?
Thank,
Cherry17
Afrow UK
1st November 2005 07:52 UTC
You need to use the /r switch on RMDir:
RMDir /r "$SMPROGRAMS\$test"
Without it, RMDir will only delete a folder if it is empty.
-Stu
Cherry17
1st November 2005 10:19 UTC
Hi Afrow,
therefore I use Delete "$SMPROGRAMS\Analyzer 1.0\*.*" It should clear the directory. I don't want to use RMDir /r because I'am afraid of killing the whole start menu if I make a mistake with the path.
I want to delete the content of the folder.
I've just tried
Delete "$SMPROGRAMS\$test\Analyzer.lnk"
Delete "$SMPROGRAMS\$test\Uninstaller.lnk"
RMDir "$SMPROGRAMS\$test"
but it doesn't work.
Thanks,
Cherry17
Afrow UK
1st November 2005 18:14 UTC
Are there any hidden files in the folder (e.g. desktop.ini)
-Stu
Instructor
1st November 2005 18:20 UTC
I want to delete them with:
Delete "$SMPROGRAMS\$test\*.*"
RMDir "$SMPROGRAMS\$test"
It does not work.
If I use
Delete "$SMPROGRAMS\Analyzer 1.0\*.*"
RMDir "$SMPROGRAMS\Analyzer 1.0"
it works.
Logically, $test variable does not contain correct value. When you run unistaller all variables is empty, so when installing you need to save variable $R0 suppose in registry, and when run unistaller read this value from registry to $temp.
Cherry17
2nd November 2005 09:09 UTC
Hi Instructor,
but I can remove the whole program. Only the shortcuts are the problem. Why can I remove the program? I thought the real values were written in the uninstaller but not the registers.
Is it wrong?
Thanks,
Kirstin
Instructor
2nd November 2005 10:15 UTC
When you runs unistaller it by default sets $INSTDIR=$EXEDIR
Cherry17
2nd November 2005 15:44 UTC
Hi Instructor,
ok. Now I can understand the problem. I don't want to write anything in the registry. I'am afraid of deleting something really important when I try to delete my entries. I will think it over.
Thanks for your help.
Kirstin
Afrow UK
2nd November 2005 15:50 UTC
Surely your startup path won't change so why should you need to store the path if it's a fixed path?
If you're scared of deleting a folder that isn't there... well you can't!
-Stu
Cherry17
3rd November 2005 09:36 UTC
Hi Afrow,
I create a folder in the startup menu. I think I have to save the name of this folder, don't I?
The user can change the name of this folder while installing the program. If he uses the default name, I will be able to remove the folder, but if he changes the name, I will not.
Thanks,
Kirstin
Cherry17
3rd November 2005 10:01 UTC
HiAfrow,
an ini-file is a great solution! I will try it.
Thank,
Kirstin
Afrow UK
3rd November 2005 10:02 UTC
In that case there is no other way but storing the folder name in the registry or in an INI file.
-Stu
Afrow UK
3rd November 2005 10:15 UTC
Strange how that happens sometimes. You posted after me but the post has gone above mine in the list.
Anyway, use WriteINIStr and ReadINIStr.
-Stu