Archive: How to prevent C:\ install


How to prevent C:\ install
Hello,

I am trying to create an installer where the user is not allowed to install the product on C drive if he belong to a group other than "Administrator". I use the plugin UserInfo to determine that. At first, I used AllowRootDirInstall = FALSE to prevent that, but even if "C:\Program Files" is selected, nothing happens. Installer continues normally without prompting user to change directory. How can I achieve that? Is there any command or something like that I can use? Any help is much appreciated!


Re: How to prevent C:\ install

Originally posted by SoundScape_2910
Hello,
At first, I used AllowRootDirInstall = FALSE to prevent that, but even if "C:\Program Files" is selected, nothing happens. Installer continues normally without prompting user to change directory. How can I achieve that? Is there any command or something like that I can use? Any help is much appreciated!
I think AllowRootDirInstall prevents you from writing on the roots of any the hard drives, it doesn't prevent you from writing on C:

What I'd do is just do a check on the first character of the $INSTDIR string (using StrCpy to get the first char) : if that character is "C", ask the user to select another path.

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "checkINSTDIR"
!insertmacro MUI_PAGE_DIRECTORY

Function checkINSTDIR
Push $R0
StrCpy $R0 $INSTDIR "" 2
StrCmp $R0 "C:" 0 NoAbort
MessageBox MB_OK|MB_ICONEXCLAMATION "Not on C: dude!"
Pop $R0
Abort
NoAbort:
Pop $R0
FunctionEnd


-Stu

Had a similar problem with a user installing our software to their desktop. When they uninstalled my script just deleted the installation directory which of course deleted everything on their desktop. Pretty funny. Well.. for me at least. Not so much for them.


Afrow UK,

MessageBox MB_OK|MB_ICONEXCLAMATION "Not on C: dude!"
LOL!!! Thanks for the code, I'll try it out.

Thanks you all, take care.

2 rsegal
.. and this is why I had to add installation folder check out and to create safe subfolder for suspicious situations in one of my programs (while we had only few such reports for 2.5 mln downloads).