41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using Microsoft.Win32;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace VMwareLauncher
|
|
{
|
|
public class ServiceControl
|
|
{
|
|
public static readonly List<string> DefaultVmwareServices = new List<string> { "VMnetDHCP", "VMUSBArbService", "VMware NAT Service", "VMwareHostd", "VMAuthdService" }; //Array of services to close
|
|
public List<string> ServiceList { get; set; }
|
|
|
|
public bool ForceServicesManual()
|
|
{
|
|
bool errors = false;
|
|
string winServices = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services";
|
|
|
|
try
|
|
{
|
|
foreach (var service in ServiceList)
|
|
{
|
|
string currentService = winServices + "\\" + service;
|
|
if ((int)Registry.GetValue(currentService, "Start", null) != 3)
|
|
{
|
|
Registry.SetValue(currentService, "Start", 3);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
errors = true;
|
|
throw;
|
|
}
|
|
|
|
return errors;
|
|
}
|
|
}
|
|
}
|