Archive: uninstall before install (both are silent) and executing batch file silently


uninstall before install (both are silent) and executing batch file silently
Hi,
I want to uninstall the previous version of my product while installing it. From example I added the following code in Function .onInit

Function .onInit
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"UninstallString"
StrCmp $R0 "" done
ExecWait "$R0"
done:
FunctionEnd

And my install and uninstall are silent.

Problem: 1. uninstall and install are happing at same time so files created using install are removed while uninstalling.
So some folders and files are missing once installation is completed. Please help me how to handle this?

2. One more query.... I am executing some batch files using EXECWAIT command while installing and uninstalling. Even though i made the installer silent, while executing bat file black screen is popped up. How to execute the batch file silently?


See:

http://nsis.sourceforge.net/When_I_u...he_uninstaller


i used ExecWait '"$INSTDIR\uninstall.exe" _?=$INSTDIR'...i am using the same location for installing and uninstalling.
the uninstall is not happaning instead installation completed sucessfully. all new file a folder are created under one fo the exsisting directory .


Don't use $INSTDIR. Use the value you read from the registry to make sure it's the right one.


Yes it is installing ...but installed location is having the problem now
I used InstallDir "$PROGRAMFILES\MyPro"
first time it is installing correctly in C:\Program Files\MyPro but the second time (i.e. uninstalling and installing) the product is installed in one of the directory previously installed.

First Time installing my product directory structure
C:\Program Files\MyPro
--aaa
--bbb
--ccc
--uninst.exe
--readme.html
Second time
C:\Program Files\MyPro
--aaa
--aaa
--bbb
--ccc
--uninst.exe
--readme.html
--uninst.exe (first product uninstall exe).how to install correctly in specified location and delete old product uninst.exe?

How to dynamically change the install directory which is set by InstallDir "$PROGRAMFILES\MyPro". Install script behave like this in general if specified InstallDir is having data then it will search for empty directory inside that and install. How to change this behavior?


i tried using this function

Function .onVerifyInstDir
StrCpy $INSTDIR "$PROGRAMFILES\CSCT"
FunctionEnd


but this also dosen't work then i copied 'StrCpy $INSTDIR "$PROGRAMFILES\CSCT" 'this line inside Section "MainSection" SEC01....now it is working fine..
is this correct way....