Unsolved In Qt Installer Framework, after installation is finished how do I run a batch file "with arguments"?
-
To open a batch file after installation is finished, we use the following code:
Component.prototype.installationFinished = function() { QDesktopServices.openUrl("file:///" + installer.value("TargetDir") + "/file.bat"); }
But I want to send two arguments to the batch file. How can I do that? Please help.
-
Why don't you use "Execute" operation?
By using it you can even have an undo command to run when uninstalling. -
@Bonnie We cannot use Execute operation in installationFinished function
Component.prototype.installationFinished = function() { }
Operations can only be added in createOperations() kind of functions which are executed during installation, not after the installation.
-
@Bonnie See this SO thread to see it doesn't work:
https://stackoverflow.com/questions/51420122/cannot-get-bat-file-to-run-after-installation-with-qt-installer -
Yes, you cannot use
addOperation
ininstallationFinished
, it is not meant to.
But I think there's no need to do that.
Operations added by addOperation after the default createOperations() are executed after the component contents are extracted to the target folder, so I consider it is run after the installation of the component.
If you arrange your components well, you don't have to run it after the whole installation.
But if you insist, I think you can tryinstaller.performOperation(name, arguments)
("Execute" as the name). -
@Bonnie Sorry for the late reply. Your line "Operations added by addOperation after the default createOperations() are executed after the component contents are extracted to the target folder, so I consider it is run after the installation of the component." helped me a lot. Your suggestion
installer.performOperation(name, arguments)
also didn't work outside createOperations(). So I did this: usingaddOperation
, I saved the arguments in a text file and then I ran the batch file as I have shown in my question.