1

The maintenance tool that is bundled with online installers for Qt applications can supposedly be run headlessly with a "--checkupdates" flag that returns update information if available (see Qt Installer Framework: Auto Update). Unfortunately I cannot get this command to actually return anything, even when there is a known update available. I can start the maintenancetool from the command line and the update is visible, but trying to use the --checkupdates flag produces nothing.

QProcess update;
update.setWorkingDirectory(QDir::currentPath());
update.start("maintenancetool --checkupdates");

// Wait until the maintenancetool is finished
update.waitForFinished();

// Read the output
QByteArray data = update.readAllStandardOutput();

I can get this code to open the maintenancetool if I remove the --checkupdates flag, but data is always empty even if there is an update. If I try and run the process in the command line it also produces nothing, so I don't think it's a problem with the code. Any ideas? There doesn't seem to be a lot of information out there about this.

Community
  • 1
  • 1
ce_nort
  • 168
  • 1
  • 16
  • Have you tried doing it using the command line? Because normally your example should work – Felix Mar 15 '16 at 17:26
  • Yes, sorry if my language was a little ambiguous: calling the maintenance tool from the command line with the --checkupdates flag creates no output. – ce_nort Mar 15 '16 at 17:32
  • 1
    Normally, this means that there are no updates available - can you see the updates if you use the UI? If yes, please check the exit-code of the --checkupdates run, if it's 0, it means updates have been found, if it's 1, there are no updates. – Felix Mar 15 '16 at 20:06
  • I can indeed see the updates if I use the UI. I just checked the exit code and it is 0, so apparently that means it is finding the updates? But if that's the case then it's unclear why there is no output. The post that I linked to indicated that the output should be caught to determine if there are updates, but it looks like perhaps I should just use the exit code to determine if there are updates and start the updater accordingly. Not ideal, but if that's my option then that's my option. – ce_nort Mar 15 '16 at 20:16

2 Answers2

1

Although I don't know the reason for it, the problem appears to be that the --checkupdates flag does not return any data. However, it does have the appropriate exit code based on whether or not there are updates available. I have rewritten my application to catch the exit code and start the maintenance tool (or not) accordingly. Feels like a hack, but it works.

ce_nort
  • 168
  • 1
  • 16
0

The maintenance tool is made to return nothing if there are no updates available. I send the results to a text file before launching the maintenance tool like this:

@echo off
maintenancetool.exe --checkupdates > checkUpdate.txt

findstr /c:"updates" checkUpdate.txt

if %errorlevel% == 0 maintenancetool.exe --script=script.qs