- Refactored code. - Fixed bug: "#1 Welcome message shows despite VMware not being installed"
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Microsoft.Win32;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace VMwareLauncher
|
|
{
|
|
public class ServiceControl
|
|
{
|
|
public static readonly List<string> VMwareServiceList = new List<string> //Array of services to close
|
|
{
|
|
"VMnetDHCP",
|
|
"VMUSBArbService",
|
|
"VMware NAT Service",
|
|
"VMwareHostd",
|
|
"VMAuthdService" };
|
|
|
|
public bool ForceServicesManual()
|
|
{
|
|
bool errors = false;
|
|
string winServices = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services";
|
|
|
|
try
|
|
{
|
|
foreach (var service in VMwareServiceList)
|
|
{
|
|
string currentService = winServices + "\\" + service;
|
|
if ((int)Registry.GetValue(currentService, "Start", null) != 3)
|
|
{
|
|
Registry.SetValue(currentService, "Start", 3);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errors = true;
|
|
throw;
|
|
}
|
|
|
|
return errors;
|
|
}
|
|
}
|
|
}
|