Skip to content

Commit c48e241

Browse files
authored
fix: disable appx identity for system setup (microsoft#258275)
* fix: external location for appx package installation * chore: revert external location
1 parent c580582 commit c48e241

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

build/win32/code.iss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ Source: "*"; Excludes: "\CodeSignSummary*.md,\tools,\tools\*,\appx,\appx\*,\reso
9595
Source: "tools\*"; DestDir: "{app}\tools"; Flags: ignoreversion
9696
Source: "{#ProductJsonPath}"; DestDir: "{code:GetDestDir}\resources\app"; Flags: ignoreversion
9797
#ifdef AppxPackageName
98+
#if "user" == InstallTarget
9899
Source: "appx\*"; DestDir: "{app}\appx"; BeforeInstall: RemoveAppxPackage; AfterInstall: AddAppxPackage; Flags: ignoreversion; Check: IsWindows11OrLater
99100
#endif
101+
#endif
100102

101103
[Icons]
102104
Name: "{group}\{#NameLong}"; Filename: "{app}\{#ExeBasename}.exe"; AppUserModelID: "{#AppUserId}"
@@ -1481,7 +1483,7 @@ function AppxPackageInstalled(var ResultCode: Integer): Boolean;
14811483
begin
14821484
AppxPackageFullname := '';
14831485
try
1484-
ExecAndLogOutput('powershell.exe', '-Command ' + AddQuotes('Get-AppxPackage -Name ''{#AppxPackageName}'' | Select-Object -ExpandProperty PackageFullName'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode, @ExecAndGetFirstLineLog);
1486+
ExecAndLogOutput('powershell.exe', '-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes('Get-AppxPackage -Name ''{#AppxPackageName}'' | Select-Object -ExpandProperty PackageFullName'), '', SW_HIDE, ewWaitUntilTerminated, ResultCode, @ExecAndGetFirstLineLog);
14851487
except
14861488
Log(GetExceptionMessage);
14871489
end;
@@ -1496,7 +1498,7 @@ var
14961498
AddAppxPackageResultCode: Integer;
14971499
begin
14981500
if not AppxPackageInstalled(AddAppxPackageResultCode) then begin
1499-
ShellExec('', 'powershell.exe', '-Command ' + AddQuotes('Add-AppxPackage -Path ''' + ExpandConstant('{app}\appx\{#AppxPackage}') + ''' -ExternalLocation ''' + ExpandConstant('{app}\appx') + ''''), '', SW_HIDE, ewWaitUntilTerminated, AddAppxPackageResultCode);
1501+
ShellExec('', 'powershell.exe', '-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes('Add-AppxPackage -Path ''' + ExpandConstant('{app}\appx\{#AppxPackage}') + ''' -ExternalLocation ''' + ExpandConstant('{app}\appx') + ''''), '', SW_HIDE, ewWaitUntilTerminated, AddAppxPackageResultCode);
15001502
end;
15011503
end;
15021504
@@ -1505,7 +1507,7 @@ var
15051507
RemoveAppxPackageResultCode: Integer;
15061508
begin
15071509
if AppxPackageInstalled(RemoveAppxPackageResultCode) then begin
1508-
ShellExec('', 'powershell.exe', '-Command ' + AddQuotes('Remove-AppxPackage -Package ''' + AppxPackageFullname + ''''), '', SW_HIDE, ewWaitUntilTerminated, RemoveAppxPackageResultCode);
1510+
ShellExec('', 'powershell.exe', '-NoLogo -NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -Command ' + AddQuotes('Remove-AppxPackage -Package ''' + AppxPackageFullname + ''''), '', SW_HIDE, ewWaitUntilTerminated, RemoveAppxPackageResultCode);
15091511
end;
15101512
end;
15111513
#endif
@@ -1611,7 +1613,9 @@ begin
16111613
exit;
16121614
end;
16131615
#ifdef AppxPackageName
1614-
RemoveAppxPackage();
1616+
#if "user" == InstallTarget
1617+
RemoveAppxPackage();
1618+
#endif
16151619
#endif
16161620
if not RegQueryStringValue({#EnvironmentRootKey}, '{#EnvironmentKey}', 'Path', Path)
16171621
then begin

0 commit comments

Comments
 (0)