Qt Installer framework Rmdir to remove directory error
-
I have a set of operations I need to perform in a sequence for my installation. Here is how it looks right now:
<Operations> <Operation name="CreateShortcut"> <Argument>@TargetDir@/App.exe</Argument> <Argument>@StartMenuDir@/App.lnk</Argument> </Operation> <Operation name="CreateShortcut"> <Argument>@TargetDir@/App.exe</Argument> <Argument>@HomeDir@/Desktop/App.lnk</Argument> </Operation> <Operation name="Mkdir"> <Argument>C:/ProgramData/DesktopApp/Config</Argument> </Operation> <Operation name="Mkdir"> <Argument>C:/ProgramData/DesktopApp/Logs</Argument> </Operation> <Operation name="CopyDirectory"> <Argument>@TargetDir@/Config</Argument> <Argument>C:/ProgramData/DesktopApp/Config</Argument> </Operation> <Operation name="CopyDirectory"> <Argument>@TargetDir@/Logs</Argument> <Argument>C:/ProgramData/DesktopApp/Logs</Argument> </Operation> <Operation name="Rmdir"> <Argument>@TargetDir@/Config</Argument> </Operation> <Operation name="Rmdir"> <Argument>@TargetDir@/Logs</Argument> </Operation> </Operations>
Installation fails with an error "Cannot remove directory /path-to-installation/Config". Same issue with removing the Logs folder as well.
I also had an issue with the CopyDirectory operation when the directory that is to be copied does not exist at the destination. Fixed it by following this issue here. Not sure if Rmdir is also somehow related to this.
The default path to my installation is C:/Program Files/ and I am using Qt installer framework 4.2
-
I figured it out. If the folders contain files then the Rmdir command fails to work. In order to make it work, I removed all the files using Delete command under the folders Config and Logs. Then, I used the command Rmdir to delete the directories successfully.
Fortunately, I only have a couple of files in the directories which I removed using Delete command. If there are many files inside the directory then I think is this not an appropriate solution. Since each file needs to be named under Delete command. Not very efficient.
There might be other ways to delete sub-folders, files recursively using Rmdir but as of now, I do not have any idea. If anyone knows how to solve this issue, feel free to add your solution.