Unsolved QtIFW: Mkdir and Delte does not work at C:
-
Hi,
i want to install my application under C:\Program Files\myapp. The follwing code will create the directory "webservices" automatically.
Component.prototype.createOperationsForArchive = function(archive) { component.addOperation("Extract", archive, "@TargetDir@/webservices"); }
But if i want to create and delete a folder like this:
var dir = installer.value("TargetDir"); component.addElevatedOperation("Delete", dir + "/webservices");
or use the installer
if(installer.isInstaller()){ if(installer.fileExists(dir +"/tmp") == true){ installer.performOperation("Delete", "@TargetDir@/tmp"); } }
it will not work.
If i use another installation directory like C:\Users it will work witouht Problems.
How can i create and delete files under C:?
best regard and thank you for your help in advance
-
You need administrator permissions to modify C:/ on modern Windowses.
-
@Schenk said in QtIFW: Mkdir and Delte does not work at C::
addElevatedOperation
I thought addElevatedOperation gaisn Admin rights?
-
@Schenk said in QtIFW: Mkdir and Delte does not work at C::
@Schenk said in QtIFW: Mkdir and Delte does not work at C::
addElevatedOperation
I thought addElevatedOperation gaisn Admin rights?
I don't know. Do you see the popup asking you to grant admin rights when you run your installer?
-
Yes, i see it, but it does not work.
I could get AdminRights on the config script with installer.gainAdminRights() and then work with performOperation(). This works.
But if i want to delete or move files after installation in the package scripts, it will not work.
Function registered:
installer.installationFinished.connect(this, Component.prototype.deleteTempFiles);
Later:
Component.prototype.deleteTempFiles = function(){ var dir = installer.value("TargetDir"); QMessageBox.information("asasas", "asasa", "dir: " + dir, QMessageBox.Ok); installer.gainAdminRights(); //component.addElevatedOperation("Delete", dir + "temp.txt"); installer.performOperation("Delete", dir + "temp.txt"); installer.dropAdminRights(); }
Neither component.addElevatedOperation() nor installer.performOperation in combination with gain and dropAdminRights() will not work in package script under C:\Program Files.
-
Ok, i found the solution:
installer.performOperation("Delete", dir + "/temp.txt"); // the slash was missing
Only this one will work
Component.prototype.deleteTempFiles = function(){ var dir = installer.value("TargetDir"); installer.gainAdminRights(); //component.addElevatedOperation("Delete", dir + "/temp.txt"); installer.performOperation("Delete", dir + "/temp.txt"); installer.dropAdminRights(); }
Try to do an elevated Operation will not work! You have to use the installer-solution.
-
Curiously, this operation works...
Component.prototype.createOperations = function() { component.createOperations(); component.addElevatedOperation("Execute", "@TargetDir@/foo.exe"); }