-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Update UseNewEnvironment parameter behavior of Start-Process cmdlet on Windows #10830
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
Update UseNewEnvironment parameter behavior of Start-Process cmdlet on Windows #10830
Conversation
92fd170
to
2f40ad7
Compare
$env:TestEnvVariable = 1 | ||
|
||
try { | ||
Start-Process $PWSH -ArgumentList '-NoProfile','-Command Write-Output $env:TestEnvVariable' -RedirectStandardOutput $outputFile -Wait |
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.
Use of CreateEnvironmentBlock() with the user token is great. Did you verify that USERNAME is correct and PATH is complete?
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.
We could check USERNAME. Checking PATH it would be that we don't trust native API.
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.
Done.
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
ddd07ba
to
ec03e45
Compare
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
@TravisEz13 @anmenaga @SteveL-MSFT Could you please review? |
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
43b2149
to
cffeaa5
Compare
cffeaa5
to
0f2b8ae
Compare
src/Microsoft.PowerShell.Commands.Management/commands/management/Process.cs
Show resolved
Hide resolved
@iSazonov would it be possible to validate these changes on nano server? |
Oh, I never have nano. Sorry. |
Verified it works on docker image for nanoserver. |
🎉 Handy links: |
PR Summary
The PR effects only Windows behavior.
See Start-Process -UseNewEnvironment provides an environment that is missing crucial standard environment variables while not supporting passing a new environment #4671 and PowerShell Committee conclusion UseNewEnvironment restores environment variables for child process #10745 (comment)
-Environment
parameter late)PR Context
Replace #10561
Fix #3545
Fix partially #4671
PowerShell Committee conclusion #10745 (comment)
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.