-
Notifications
You must be signed in to change notification settings - Fork 75
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
Avoid error when installing packages in headless mode #1266
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
Thank for your contribution @thack1! You need to sign Google CLA, otherwise we are not able to merge your PR.
Please also rebase to fix the version update conflict and see my improvement suggestion. 😉
@@ -2,7 +2,7 @@ | |||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | |||
<metadata> | |||
<id>common.vm</id> | |||
<version>0.0.0.20250124</version> | |||
<version>0.0.0.20250204</version> |
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 have just merged a PR that updated this package, so there is now a merge conflict here. @thack1 can you please fix it?
@@ -1534,7 +1534,7 @@ public class Shell { | |||
$SHCNF_IDLIST = 0 | |||
[void][Shell]::SHChangeNotify($SHCNE_ASSOCCHANGED, $SHCNF_IDLIST, [IntPtr]::Zero, [IntPtr]::Zero) | |||
# Refresh the Taskbar | |||
Stop-Process -Name explorer -Force # This restarts the explorer process so that the new taskbar is displayed. | |||
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue # This restarts the explorer process so that the new taskbar is displayed. |
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 think using -ErrorAction Continue
would still prevent this from failing (fixing the issue you are encoutering) and display the error, which I think it is in general useful.
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue # This restarts the explorer process so that the new taskbar is displayed. | |
Stop-Process -Name explorer -Force -ErrorAction Continue # This restarts the explorer process so that the new taskbar is displayed. |
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.
[nitpick] I think it would be a good idea to document why the -ErrorAction Continue
is needed (to avoid we forget about the reason and delete it). The current comments are a bit confusing (as we have two comments saying the same, one more detailed). Proposal:
# Restart the explorer process to refresh the taskbar.
# Use '-ErrorAction Continue' to avoid failing the package installation if it fails,
# for example if there is no desktop session (as in this case explorer.exe is not running)
Stop-Process -Name explorer -Force -ErrorAction Continue
Question (unrelated to this PR but I am curious): @thack1 are you able to install packages like |
VM-Refresh-Desktop tries to restart explorer.exe by using the Stop-Process cmdlet. When installing VM-Packages without a desktop session running (e.g. using ansible) this results in an error, because explorer.exe is not running. This error can be avoided by using ErrorAction SilentlyContinue.
ERROR: Cannot find a process with name "explorer".