Archive: Delete shortcuts in start menu


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


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


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


Are there any hidden files in the folder (e.g. desktop.ini)

-Stu


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.

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


When you runs unistaller it by default sets $INSTDIR=$EXEDIR


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


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


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


HiAfrow,

an ini-file is a great solution! I will try it.

Thank,
Kirstin


In that case there is no other way but storing the folder name in the registry or in an INI file.

-Stu


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