I use qt installer framework to create installer. On installation step I called
component.addOperation("Mkdir", dataDir); // dataDir is a dataLocationDir like C:\Users\Stranger\AppData\Local\MyAppName
When my installed program working it put some folders and files into dataLocationDir, at this way UNDO step of "Mkdir" operation does not work correctly when i runned uninstall. I try use "Execute" command like this:
component.addOperation("Execute", "mkdir " + dataDir, "UNDOEXECUTE", "del /S /F" + dataDir);
and also i tried
component.addOperation("Execute", "cmd /C mkdir " + dataDir, "UNDOEXECUTE", "cmd /C del /S /F" + dataDir);
but this methods cancel with error "Could not start: 'mkdir my/path'(No program defined)"

- 21
- 1
- 5
3 Answers
You said you tried both
component.addOperation("Execute", "mkdir " + dataDir, "UNDOEXECUTE", "del /S /F" + dataDir);
and
component.addOperation("Execute", "cmd", "/C", "mkdir", dataDir, "UNDOEXECUTE", "cmd ", "/C", "rmdir", "/S", /Q", dataDir);
I think the right way is the first one, with the syntax of the second:
component.addOperation("Execute", "mkdir", dataDir, "UNDOEXECUTE", "del", "/S", "/F", dataDir);
The first one did not work because you have to separate the executable from the arguments. If Qt gets a single string, it assumes it's your executable full path. The second one actually should work, since you can run (in a cmd for instance) "cmd /c mkdir yourPath" and it works as intended. Anyway, I've tested and used the solution I propose. If it doesn't work, make sure you escape your backslashes correctly in your path.

- 314
- 2
- 10
I've faced the same problem.
In short it looks like the operations on directories of QtIFW are buggy.
Under Windows I've solved in this way:
- I've created a batch file which manages an input argument "add" during the installation and an input argument "delete" when during the deinstallation.
- I've put it in the resource file of the installer.
In the constructor of the component I am moving this script to the installation directory:
installer.performOperation("Copy", ["://myfile.bat", installer.value("TargetDir")]);
In createOperations of Component there is:
component.addOperation("Execute", ["cmd", "/c", "@TargetDir@\\myfile.bat", "add", "workingDirectory=@TargetDir@", "UNDOEXECUTE", "cmd", "/c", "@TargetDir@\\myfile.bat", "delete", "workingDirectory=@TargetDir@"]);
In finishPageCallback of Controller I remove the batch in this way:
installer.performOperation("Delete", installer.value("TargetDir") + "\\myfile.bat"));

- 77
- 1
- 4
This is an installer error in the operation of the Mkdir operation.
I got around this using the controller script.
Controller.prototype.FinishedPageCallback = function()
{
if (installer.isUninstaller() && installer.status == QInstaller.Success) {
var pathToconfigMyapp = QDesktopServices.storageLocation(QDesktopServices.GenericDataLocation) + "\\Myapp";
if(installer.fileExists(pathToconfigMyapp) === true){
installer.executeDetached("cmd",["/c", "rd", "/q", "/s", pathToconfigMyapp]);
}
gui.clickButton(buttons.FinishButton);
}

- 1
- 3
component.addOperation("Execute", "cmd", "/C", "mkdir", dataDir, "UNDOEXECUTE", "cmd ", "/C", "rmdir", "/S", /Q", dataDir);
. But it return error message "Execution failed (Unexpected exit code 1): cmd /C mkdir C:\User\Staranger\AppData\Local\MyPath" – Leonid Leshukov Nov 21 '16 at 07:19