Skip to content

Commit

Permalink
Merge pull request CosmosOS#478 from MellenIO/master
Browse files Browse the repository at this point in the history
Builder changes - better detection for VMware Player
  • Loading branch information
charlesbetros authored Oct 23, 2016
2 parents a277900 + e9ae271 commit afdc5a3
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions source/Cosmos.Build.Builder/CosmosTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,33 @@ protected int NumProcessesContainingName(string name)
return (from x in Process.GetProcesses() where x.ProcessName.Contains(name) select x).Count();
}

protected bool IsVMWareInstalled()
{
//Check registry keys
if (CheckForInstall("VMware Workstation", false)) {
return true;
}
if (CheckForInstall("VMware Player", false)) {
return true;
}
if (CheckForInstall("VMwarePlayer_x64", false)) {
return true;
}

try //Try/catch block since the reg key might not exist, we might not have perms etc.
{
using (var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\VMware, Inc.\VMware Player"))
{
return true; //Just assume that because we have the key, we've installed
//return (key.GetValue("ProductCode") != null); //On successful install, ProductCode should be set (we don't care what the value is, but we care that it exists)
}
}
catch
{ //TODO: check directories?
return false;
}
}

protected bool CheckForInstall(string aCheck, bool aCanThrow)
{
return CheckForProduct(aCheck, aCanThrow, @"SOFTWARE\Classes\Installer\Products\", "ProductName");
Expand Down Expand Up @@ -357,18 +384,9 @@ protected void CheckPrereqs()
CheckNet35Sp1(); // Required by VMWareLib and other stuff
CheckNet403();
CheckForInno();
bool vmWareInstalled = true;
bool vmWareInstalled = IsVMWareInstalled();
bool bochsInstalled = IsBochsInstalled();
if (!CheckForInstall("VMware Workstation", false))
{
if (!CheckForInstall("VMware Player", false))
{
if (!CheckForInstall("VMwarePlayer_x64", false))
{
vmWareInstalled = false;
}
}
}

if (!vmWareInstalled && !bochsInstalled)
{
NotFound("VMWare or Bochs");
Expand Down

0 comments on commit afdc5a3

Please sign in to comment.