Solved How to set access rights in folders with the Qt Installer Framework
-
Hi everyone,
I'm trying to use the Installer Framework on Windows to install my app to "C:\Program Files\My Company\MyApp".
And my App uses some config files (read and write) in "C:\ProgramData\My Company\MyApp", so I want to create this folder and set the access rights.No I have the problem, that the folder should remain, even after uninstalling the software.
-
This is working, but the folder is deleted during uninstall.
var dataDir = "C:\ProgramData\My Company\MyApp"; component.addOperation( "Mkdir", dataDir );
-
This does not work in any configuration, I even tried without spaces in the folder name.
var dataDir = "C:\ProgramData\My Company\MyApp"; component.addOperation( "Execute", "mkdir " + dataDir, "UNDOEXECUTE" ); // or this one component.addOperation( "Execute", "mkdir", dataDir, "UNDOEXECUTE" );
I get the following errors:
- Cannot start: "mkdir C:\ProgramData\My Company\MyApp": Process Failed to start: No such file or directory
- Cannot start: "mkdir C:\ProgramData\My_Company\MyApp": Process Failed to start: No such file or directory
-
I also tried a batch file to call mkdir, and this is working. But I want to know if there is a better way from inside the installer to create a folder with spaces in the folder name, which is not beeing deleted during uninstall?
regards
Oliver -
-
I found part of a solution myself.
This is working when the folder name does not contain spaces.installer.executeDetached( "cmd", "/C mkdir C:\\ProgramData\\My_Company\\MyApp", "@TargetDir@" );
A solution with spaces is still required.
-
@stvokr You need to put the path into "" to make sure it works with paths containing spaces.
installer.executeDetached( "cmd", "/C mkdir \"C:\\ProgramData\\My_Company\\MyApp\"", "@TargetDir@" );
-
@jsulm I forgot to mention, that I already tried masking the quotes. That did not work.
-
@stvokr According to https://doc.qt.io/qtinstallerframework/scripting-installer.html#executeDetached-method it is actually not needed: "Windows: Arguments that contain spaces are wrapped in quotes.".
There is something you're doing wrongly I think. Take a look at this:boolean executeDetached(string program, stringlist arguments = undefined, string workingDirectory = "")
The parameters must be passed as a string list. You're passing all parameters as one string.
-
@jsulm Hi, if I pass the parameters a string list
installer.executeDetached( "cmd", "/C", "mkdir", "My_Complany", "C:\\ProgramData\\" ) );
the InstallationLog.txt tells me,
"run application as detached process: "cmd" ("/C") "mkdir"
and that the operation has returned false. So the given parameter "My_Company" has somehow not been passed.
-
So, finally, I got a solution (even 2 solutions):
brackets.installer.executeDetached( "cmd", ["/C", "mkdir", "C:\\ProgramData\\My Company\\MyApp"], "C:\\ProgramData" );
With this trick even the addOperation() function works fine:
component.addOperation( "Execute", "cmd", ["/C", "mkdir", C:\\ProgramData\\My Company\\MyApp"] );
I think this is closed.