UpdateManagerWin32.cpp 919 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // Created by msn on 2016-02-16.
  3. //
  4. #include "UpdateManagerWin32.h"
  5. #include "Paths.h"
  6. #include "QsLog.h"
  7. #include <QFile>
  8. #include <QDir>
  9. #include <QProcess>
  10. /////////////////////////////////////////////////////////////////////////////////////////
  11. bool UpdateManagerWin32::applyUpdate(const QString& version)
  12. {
  13. QString updateExe = GetPath("PlexMediaPlayer-" + version + "-windows-x64.exe", version, true);
  14. if(QFile::exists(updateExe))
  15. {
  16. QStringList args;
  17. args << "/passive" << "/norestart" << "/log" << Paths::logDir("Plex Media Player Installer.log");
  18. args << "autolaunch=1";
  19. QFile::remove(GetPath("_readyToApply", version, false));
  20. if (QProcess::startDetached(updateExe, args, QDir::temp().absolutePath()))
  21. {
  22. QLOG_DEBUG() << "Running update...";
  23. return true;
  24. }
  25. }
  26. else
  27. {
  28. QLOG_WARN() << "Failed to find update file:" << updateExe;
  29. }
  30. return false;
  31. }