Skip to content

Instantly share code, notes, and snippets.

@momo-the-monster
Created August 6, 2021 00:48
Show Gist options
  • Save momo-the-monster/4a0a44de3940a92d321ca2da255250f2 to your computer and use it in GitHub Desktop.
Save momo-the-monster/4a0a44de3940a92d321ca2da255250f2 to your computer and use it in GitHub Desktop.
Add Folder to Environment Path in C#
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