Created
August 6, 2021 00:48
-
-
Save momo-the-monster/4a0a44de3940a92d321ca2da255250f2 to your computer and use it in GitHub Desktop.
Add Folder to Environment Path in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UnityEditor; | |
using UnityEngine; | |
public class SetGitPath : MonoBehaviour | |
{ | |
[InitializeOnLoadMethod] | |
// Start is called before the first frame update | |
public static void Initialize() | |
{ | |
var name = "PATH"; | |
var scope = EnvironmentVariableTarget.User; | |
var oldValue = Environment.GetEnvironmentVariable(name, scope); | |
string targetPath = @";C:\Users\momod\AppData\Local\GitHubUnity\git\cmd"; | |
if (!oldValue.Contains(targetPath)) | |
{ | |
Environment.SetEnvironmentVariable(name, oldValue + targetPath, scope); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment