Skip to content

Commit da366b8

Browse files
committed
Fixed: Execution of unprotect when user name contains space.
1 parent d640d8d commit da366b8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

source/Reloaded.Mod.Launcher.Lib/Utility/TryUnprotectGamePassGame.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,19 @@ public static bool TryIt(string exePath)
4343

4444
// Execute the script in game context where we have perms to access the files.
4545
var scriptPath = Path.Combine(tempDir.FolderPath, "files.txt");
46+
var scriptFile = Path.Combine(tempDir.FolderPath, "script.ps1");
47+
var scriptContents = $"Invoke-CommandInDesktopPackage -PackageFamilyName '{packageFamilyName}' -AppId '{appId}' -Command '{compressedLoaderPath}' -Args \"`\"{scriptPath}`\"\"";
4648
File.WriteAllLines(scriptPath, exeFiles, Encoding.UTF8);
49+
File.WriteAllText(scriptFile, scriptContents, Encoding.UTF8);
4750

4851
// Run the script
49-
var command = $"-NoProfile -ExecutionPolicy ByPass -Command \"Invoke-CommandInDesktopPackage -PackageFamilyName '{packageFamilyName}' -AppId '{appId}' -Command '{compressedLoaderPath}' -Args '{scriptPath}'\"";
52+
var command = $"-NoProfile -ExecutionPolicy ByPass -File \"{scriptFile}\"";
5053
var processStartInfo = new ProcessStartInfo
5154
{
5255
FileName = @"powershell",
5356
Arguments = command,
5457
CreateNoWindow = true,
55-
WindowStyle = ProcessWindowStyle.Hidden,
58+
WindowStyle = ProcessWindowStyle.Hidden
5659
};
5760

5861
using var process = Process.Start(processStartInfo);
@@ -62,7 +65,7 @@ public static bool TryIt(string exePath)
6265
var processName = "replace-files-with-itself";
6366
while (Process.GetProcessesByName(processName).Length > 0)
6467
Thread.Sleep(1);
65-
68+
6669
return true;
6770
}
6871

0 commit comments

Comments
 (0)