C# – First steps with C# and .NET – part 064.

This is a simple example of how to add to the Environment Variable variable Path a simple path read on the admin console.
This code first retrieves the current system environment variables using the Environment.GetEnvironmentVariables method.
Create a simple project with dotnet tool and add this source code:

Depending on the system security level you can add an app.manifest file with this source code in order to avoid running on console administrator:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.