Skip to content

Commit b240cdc

Browse files
alessandroampalaXcedf
authored andcommitted
Fix update on windows when path contains powershell wildcards (shadps4-emu#1391) (shadps4-emu#1779)
* Fix update process on windows when there are some powershell wildcards in the installation path. (shadps4-emu#1391) * Fix coding style error. (shadps4-emu#1391)
1 parent 380cf2a commit b240cdc

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/qt_gui/check_update.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,11 @@ void CheckUpdate::DownloadUpdate(const QString& url) {
347347

348348
QString userPath;
349349
Common::FS::PathToQString(userPath, Common::FS::GetUserPath(Common::FS::PathType::UserDir));
350+
#ifdef Q_OS_WIN
351+
QString tempDownloadPath = QString(getenv("LOCALAPPDATA")) + "/Temp/temp_download_update";
352+
#else
350353
QString tempDownloadPath = userPath + "/temp_download_update";
354+
#endif
351355
QDir dir(tempDownloadPath);
352356
if (!dir.exists()) {
353357
dir.mkpath(".");
@@ -393,6 +397,11 @@ void CheckUpdate::Install() {
393397
QString processCommand;
394398

395399
#ifdef Q_OS_WIN
400+
// On windows, overwrite tempDirPath with AppData/Local/Temp folder
401+
// due to PowerShell Expand-Archive not being able to handle correctly
402+
// paths in square brackets (ie: ./[shadps4])
403+
tempDirPath = QString(getenv("LOCALAPPDATA")) + "/Temp/temp_download_update";
404+
396405
// Windows Batch Script
397406
scriptFileName = tempDirPath + "/update.ps1";
398407
scriptContent = QStringLiteral(
@@ -408,10 +417,11 @@ void CheckUpdate::Install() {
408417
"Start-Sleep -Seconds 3\n"
409418
"Copy-Item -Recurse -Force '%2\\*' '%3\\'\n"
410419
"Start-Sleep -Seconds 2\n"
411-
"Remove-Item -Force '%3\\update.ps1'\n"
412-
"Remove-Item -Force '%3\\temp_download_update.zip'\n"
413-
"Start-Process '%3\\shadps4.exe'\n"
414-
"Remove-Item -Recurse -Force '%2'\n");
420+
"Remove-Item -Force -LiteralPath '%3\\update.ps1'\n"
421+
"Remove-Item -Force -LiteralPath '%3\\temp_download_update.zip'\n"
422+
"Remove-Item -Recurse -Force '%2'\n"
423+
"Start-Process -FilePath '%3\\shadps4.exe' "
424+
"-WorkingDirectory ([WildcardPattern]::Escape('%3'))\n");
415425
arguments << "-ExecutionPolicy"
416426
<< "Bypass"
417427
<< "-File" << scriptFileName;

0 commit comments

Comments
 (0)