Command.cs
/// <summary>
/// Removes all values that contain current directory from User Path environment variable
/// </summary>
Removes all values that contain current directory from User Path environment variable
Removes all values that contain current directory from User Path environment variable
protected void RemoveAllFromPath()
        {
            var name = "PATH";
            var scope = EnvironmentVariableTarget.User;
            var oldValue = Environment.GetEnvironmentVariable(name, scope);
            var paths = oldValue.Split(';');
            var currentPath = this.ExecutableLocationDirectory;
            var newPaths = paths.Where(path => !path.Contains(currentPath)).ToArray();
            var newValue = string.Join(';', newPaths);
            Environment.SetEnvironmentVariable(name, newValue, scope);
        }
protected void RemoveAllFromPath ( ) { var name = " " ; var scope = EnvironmentVariableTarget . User ; var oldValue = Environment . GetEnvironmentVariable ( name , scope ) ; var paths = oldValue . Split ( ' ' ) ; var currentPath = this . ExecutableLocationDirectory ; var newPaths = paths . Where ( path => ! path . Contains ( currentPath ) ) . ToArray ( ) ; var newValue = string . Join ( ' ' , newPaths ) ; Environment . SetEnvironmentVariable ( name , newValue , scope ) ; }
Removes all values that contain current directory from User Path environment variable
Removes all values that contain current directory from User Path environment variable