-
Notifications
You must be signed in to change notification settings - Fork 168
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
Windows: Report installation messages to console #847
Merged
Merged
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
143b914
Draft support for stdout logging
jaimergp a6c78d3
Homogeneize stdout messaging
jaimergp b11ecf3
this should be silent too
jaimergp 14f026f
test stdout
jaimergp a8ddc50
fix has_license check
jaimergp a32620f
Check NSIS version properly
jaimergp 52e7688
has_license fix again
jaimergp 55e8e83
reformat /? message
jaimergp 747d88e
ship license file and refer to it during silent install
jaimergp 815a14d
pre-commit
jaimergp f7636e6
add news
jaimergp f116140
adjust error message and general Windows assertions
jaimergp 32563bf
adjust docs
jaimergp 1a9029f
send unquoted version too
jaimergp 73d333c
add /Q flag
jaimergp 691f134
Merge branch 'main' into nsis-log-stdout
jaimergp 7193751
Fix and clarify stream redirection
jaimergp de79678
Merge branch 'nsis-log-stdout' of github.com:jaimergp/constructor int…
jaimergp 0fb70c6
better docs for quiet mode
jaimergp e4172e9
suggest powershell
jaimergp 379679d
add help to uninstaller too
jaimergp 37af49d
Reformat examples for both CMD and Powershell
jaimergp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -69,65 +69,83 @@ Windows installers have the following CLI options available: | |||||
- `/RegisterPython=[0|1]`: Whether to register Python as default in the Windows registry. Defaults | ||||||
to `1`. This is preferred to `AddToPath`. | ||||||
- `/Q` (quiet): do not report to the console in headless mode. Only relevant when used with `/S` | ||||||
(see below). | ||||||
(see below). Also works for the uninstallers. | ||||||
|
||||||
You can also supply [standard NSIS flags](https://nsis.sourceforge.io/Docs/Chapter3.html#installerusage), but only _after_ the ones mentioned above: | ||||||
|
||||||
- `/NCRC`: disables the CRC check. | ||||||
- `/S` (silent): runs the installer or uninstaller in headless mode. Installers created with | ||||||
`constructor 3.10` or later will report information to the active console. | ||||||
`constructor 3.10` or later will report information to the active console. Note that while the | ||||||
installer output will be reported in the active console, the uninstaller output will happen in | ||||||
a new console. See below for different invocation examples. | ||||||
- `/D` (directory): sets the default installation directory. Note that even if the path contains | ||||||
spaces, it must be the last parameter used in the command line and must not contain any quotes. | ||||||
Only absolute paths are supported. The uninstaller uses `_?` instead of `/D`. | ||||||
|
||||||
### Examples: | ||||||
|
||||||
> Note that the NSIS installers will not write any output to the terminal. You will not see any | ||||||
> output, even if the installation fails. You can check the Task Manager to see if the installer is | ||||||
> running, or poll the installation directory to see if the installation has finished. | ||||||
### Examples | ||||||
|
||||||
Run the installer in silent mode: | ||||||
Run the installer in headless mode: | ||||||
|
||||||
```batch | ||||||
> cmd.exe /c start /wait my_installer.exe /S | ||||||
`````{tab-set} | ||||||
````{tab-item} CMD | ||||||
```pwsh | ||||||
cmd.exe /C start /wait my_installer.exe /S | ||||||
``` | ||||||
|
||||||
Run the installer in silent mode and install to a custom path: | ||||||
|
||||||
```batch | ||||||
> cmd.exe /c start /wait my_installer.exe /InstallationType=AllUsers /AddToPath=1 /S /D=C:\Program Files\my_app | ||||||
```` | ||||||
````{tab-item} PowerShell | ||||||
```pwsh | ||||||
Start-Process -FilePath .\my_installer.exe -ArgumentList "/S" -NoNewWindow -Wait | ||||||
``` | ||||||
```` | ||||||
````` | ||||||
|
||||||
Run the uninstaller in silent mode from its original location: | ||||||
Run the installer in headless mode, for all users, adding to PATH and installing to a custom path: | ||||||
|
||||||
```batch | ||||||
> cmd.exe /c start /wait "C:\Program Files\my_app\uninstaller.exe" /S _?=C:\Program Files\my_app | ||||||
|
||||||
`````{tab-set} | ||||||
````{tab-item} CMD | ||||||
```pwsh | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
cmd.exe /C start /wait my_installer.exe /InstallationType=AllUsers /AddToPath=1 /S /D=C:\Program Files\my_app | ||||||
``` | ||||||
```` | ||||||
````{tab-item} PowerShell | ||||||
```pwsh | ||||||
Start-Process -FilePath .\my_installer.exe -ArgumentList "/InstallationType=AllUsers /AddToPath=1 /S /D=C:\Program Files\my_app" -NoNewWindow -Wait | ||||||
``` | ||||||
```` | ||||||
````` | ||||||
|
||||||
:::{admonition} Stream redirection in EXE installers | ||||||
:class: info | ||||||
Redirect the console output to a file named `log.txt`: | ||||||
|
||||||
When run in `/S` mode, EXE installers will output some minimal info to the console when invoked | ||||||
like this: | ||||||
|
||||||
```batch | ||||||
> cmd.exe /c start /wait my_installer.exe /S | ||||||
`````{tab-set} | ||||||
````{tab-item} CMD | ||||||
```pwsh | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
my_installer.exe /S > log.txt | ||||||
``` | ||||||
|
||||||
This call waits until the installer is done. However, stream redirection won't work like this: | ||||||
|
||||||
```batch | ||||||
> cmd.exe /c start /wait my_installer.exe /S > logs.txt | ||||||
> Stream redirection only works if the installer is invoked directly. Unfortunately this means that the call won't block and the installer will run in the background. If you need to block on the call, you can poll `log.txt` until you find `Done!` or `:error:`. We strongly recommend the Powershell alternative instead. | ||||||
```` | ||||||
````{tab-item} PowerShell | ||||||
```pwsh | ||||||
Start-Process -FilePath .\my_installer.exe -ArgumentList "/S" -NoNewWindow -Wait -RedirectStandardOutput log.txt | ||||||
``` | ||||||
```` | ||||||
````` | ||||||
|
||||||
Stream redirection does work as expected if run directly: | ||||||
Run the uninstaller in headless mode from its original location: | ||||||
|
||||||
```batch | ||||||
> my_installer.exe /S > logs.txt | ||||||
`````{tab-set} | ||||||
````{tab-item} CMD | ||||||
```pwsh | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
cmd.exe /C start /wait C:\Program Files\my_app\uninstaller.exe /S _?=C:\Program Files\my_app | ||||||
``` | ||||||
|
||||||
Unfortunately, in this case the call won't block. You will have to poll the `logs.txt` file and block until finished (e.g. you find `Done!` or `:error:`). | ||||||
::: | ||||||
```` | ||||||
````{tab-item} PowerShell | ||||||
```pwsh | ||||||
Start-Process -FilePath C:\Program Files\my_app\uninstaller.exe -ArgumentList "/S _?=C:\Program Files\my_app" -NoNewWindow -Wait | ||||||
``` | ||||||
```` | ||||||
````` | ||||||
|
||||||
:::{admonition} EXE installers with file logging | ||||||
:class: tip | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used pwsh on purpose here because the batch syntax highlighting didn't shown any colours at all.