How can I make my console app installable so that when I open CMD I can run it from anywhere with a keyword. Like when I type in git
in cmd for example. Thanks.
Asked
Active
Viewed 93 times
-2

Jim Layhey
- 353
- 5
- 13
-
Create an installer similar to Git for Windows, and modify Windows path environment variable. – Lex Li May 27 '18 at 14:22
1 Answers
0
For this, you need to set up an environment variable called PATH. In Windows, it is in the registry. But for Mac or Linux you may want to update the .bash_profile file.
You can use the following function
SetEnvironmentVariable(String, String)
Here is the link for the MSDN .net core API
Then again I haven't tried this before. But hope this helps you out.

anuradha
- 123
- 1
- 9
-
Close, you need to call `SetEnvironmentVariable(String, String, EnvironmentVariableTarget)` with `EnvironmentVariableTarget.Machine` or `EnvironmentVariableTarget.User` passed in. If you don't set the 3rd parameter the changes will only be local to the process and will be gone when the process closes. – Scott Chamberlain May 27 '18 at 15:01