Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installer - Run PowerShell hidden and with -NoProfile when installing silently #2515

Closed
o-l-a-v opened this issue Nov 2, 2024 · 3 comments
Closed
Milestone

Comments

@o-l-a-v
Copy link

o-l-a-v commented Nov 2, 2024

Context

Following command:

winget install --silent --id WinMerge.WinMerge --scope user

Downloads and installs https://github.com/WinMerge/winmerge/releases/download/v2.16.44/WinMerge-2.16.44-x64-PerUser-Setup.exe with /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART.

In the middle of the installation a visible PowerShell window pops up, and it is loading the PowerShell profile before installing.

Feature requests

  1. Run PowerShell hidden from the installer with something like PowerShell.exe -WindowStyle hidden
  2. Don't load the PowerShell profile, use PowerShell.exe -NoProfile.

Example command I've successfully used from Intune when running PowerShell scripts in user context in the past:

"%SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy "Bypass" `
    -NoLogo -NonInteractive -NoProfile -WindowStyle "Hidden" `
    -Command "& '.\User_Install-ClientTroubleshootingTools.ps1'; exit $LASTEXITCODE"

Workaround

Use Scoop: scoop install extras/winmerge.

@sdottaka
Copy link
Member

Sorry for the late response.

  1. Is there any reason to hide the Powershell window other than it looks bad? (I want to keep the Powershell window because it shows the progress of the shell extension installation.)

  2. Am I correct in understanding that adding the -NoProfile command line option can avoid environment-dependent issues?

@o-l-a-v
Copy link
Author

o-l-a-v commented Nov 18, 2024

  1. I think the most common understanding of what quiet / silent actually implies is to show nothing. That's also what the Inno Setup switched passed by WinGet (/VERYSILENT) implies (link below). If you want progress to be shown, don't pass /VERYSILENT, but /SILENT.
  2. Yes, correct. You'll run "vanilla" PowerShell that way.

sdottaka added a commit that referenced this issue Nov 18, 2024
…alled during uninstallation

- #2515 Installer - Run PowerShell hidden and with -NoProfile when installing silently
@sdottaka
Copy link
Member

The -NoProfile -WindowStyle "Hidden" command line options have been added in commit 2537e21.
However, due to the following issue, the window appears for just a moment. We welcome PRs on this issue.
PowerShell/PowerShell#3028

@sdottaka sdottaka added this to the v2.16.45.0 milestone Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants