2017-03-03 05:04:03 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
2015-11-25 01:48:58 +00:00
|
|
|
|
using System.Linq;
|
2016-02-19 17:06:21 +00:00
|
|
|
|
using Microsoft.Win32;
|
2015-11-25 01:48:58 +00:00
|
|
|
|
|
|
|
|
|
namespace Dotnet.Cli.Msi.Tests
|
|
|
|
|
{
|
|
|
|
|
class Utils
|
|
|
|
|
{
|
|
|
|
|
internal static bool ExistsOnPath(string fileName)
|
|
|
|
|
{
|
|
|
|
|
var paths = GetCurrentPathEnvironmentVariable();
|
|
|
|
|
return paths
|
|
|
|
|
.Split(';')
|
|
|
|
|
.Any(path => File.Exists(Path.Combine(path, fileName)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static string GetCurrentPathEnvironmentVariable()
|
|
|
|
|
{
|
2017-03-03 05:04:03 +00:00
|
|
|
|
var hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
|
2015-11-25 01:48:58 +00:00
|
|
|
|
var regKey = hklm.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", false);
|
|
|
|
|
|
|
|
|
|
return (string)regKey.GetValue("Path");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|