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

Make refreshenv.bat error if powershell.exe is being used #1392

Closed
ferventcoder opened this issue Aug 27, 2017 · 10 comments · Fixed by #2756
Closed

Make refreshenv.bat error if powershell.exe is being used #1392

ferventcoder opened this issue Aug 27, 2017 · 10 comments · Fixed by #2756
Assignees
Milestone

Comments

@ferventcoder
Copy link
Member

ferventcoder commented Aug 27, 2017

If someone has the powershell profile installed, they would never call this as refreshenv is an alias for Update-SessionEnvironment.

This is quite difficult to determine. I found https://stackoverflow.com/a/16376399/18475, but it won't work if you drop from PowerShell.exe to cmd.exe to run commands, and I haven't found a way to capture the current title and set it back yet.

It also doesn't determine the difference between cmd started up just to run a batch and a long term child process of cmd.exe that you get if you open PowerShell and then drop into cmd.exe (call cmd.exe in PowerShell opens a child process). The script found can not tell the difference between the two.

@beatcracker
Copy link

I think I've solved this problem: beatcracker/choco@9e0d484 . Unfortunately I don't feel like signing CLA. Could you use my solution if I to release it separetely with some very permissive license (WTFPL or something like that)?

@ferventcoder
Copy link
Member Author

@beatcracker how will this work if say I'm in powershell.exe and then call cmd.exe to go into that prompt before calling refreshenv?

@ferventcoder
Copy link
Member Author

Looks like it could work. Don't feel like signing the CLA or are unable to?

@beatcracker
Copy link

beatcracker commented Oct 23, 2017

how will this work if say I'm in powershell.exe and then call cmd.exe to go into that prompt before calling refreshenv?

It will refresh env. vars inside that cmd session. But if you run it as RefreshEnv.cmd from PS console it will show the warning. I've tested this in both PS console and ISE.

Don't feel like signing the CLA or are unable to?

Don't feel like. It requires sharing my personal data and this is something I'm very reluctant to do. Sorry about that.

@ferventcoder
Copy link
Member Author

It requires sharing my personal data and this is something I'm very reluctant to do.

Understood. It probably won't help, but the data goes nowhere. We don't share it with anyone.

Set up something generic in a repository and give it a very permissive license. Then we can take a closer look.

@beatcracker
Copy link

Set up something generic in a repository and give it a very permissive license. Then we can take a closer look.

Sure, will MIT be suitable?

@ferventcoder
Copy link
Member Author

MIT is perfect.

@beatcracker
Copy link

@ferventcoder ferventcoder modified the milestones: 0.10.10, 0.10.12 Mar 27, 2018
@ferventcoder ferventcoder modified the milestones: 0.10.12, 0.10.13 May 3, 2018
@ferventcoder ferventcoder modified the milestones: 0.10.13, 0.10.14, 0.10.15 Mar 9, 2019
@ferventcoder ferventcoder modified the milestones: 0.10.15, 0.10.16 Apr 1, 2019
@gep13 gep13 modified the milestones: 0.10.16, 0.10.17 May 31, 2019
@ferventcoder ferventcoder modified the milestones: 0.10.17, 0.10.18 Jan 14, 2020
@ferventcoder ferventcoder modified the milestones: 0.10.18, 0.10.x Apr 14, 2021
@corbob corbob self-assigned this Apr 22, 2022
@corbob
Copy link
Member

corbob commented Apr 22, 2022

So I took the sample code from @beatcracker for a spin (as well as previously having done some investigating on this myself). I had hoped to use a separate file that could be fully attributed to beatcracker, but it appears that's not possible (if you call the cmd from within a cmd, it detects as being run interactively 😅 ).

I have a bit of work to do to get it ready for a PR, but should have a PR up for this by the end of the month 😄

corbob added a commit to corbob/choco that referenced this issue Jun 30, 2022
Detect when the calling shell is not cmd.exe and issue a message that it
does not work on that shell.
vexx32 added a commit that referenced this issue Sep 30, 2022
(#1392) Update refreshenv to detect when not in cmd shell
@gep13
Copy link
Member

gep13 commented Oct 2, 2022

@vexx32 can you update this issue with the milestone is this work intended to go out on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants