5 Commits

Author SHA1 Message Date
f5b9c8f7a7 [VMware Launcher 2.0.9.7]
- Enhancement: #4 Verify Windows services have properly terminated upon shutdown.
- Moved instanciation of ServiceControl class from Startup.xaml.cs to StatusWindow.xaml.cs.
2021-04-13 12:04:14 +01:00
a9d7e48fac [VMware Launcher 2.0.9.6]
- Enhancement: Improved alignment of VMware logo in background image.
2021-03-31 20:57:58 +01:00
9d7bfbe6b9 [VMware Launcher 2.0.9.6]
- Enhancement: #3 Update Splash Screen
2021-03-27 15:20:21 +00:00
908a005812 Added .gitignore for build and debug files. 2021-03-26 20:21:25 +00:00
6d7fec03b4 [VMware Launcher 2.0.9.5]
- Refactored code.
- Fixed bug: "#1 Welcome message shows despite VMware not being installed"
2021-03-26 20:20:46 +00:00
20 changed files with 157 additions and 105 deletions
Vendored
+2
View File
@@ -0,0 +1,2 @@
VmwareLauncher/obj/
VmwareLauncher/bin/Debug/
Binary file not shown.
+10 -7
View File
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.21005.1
# Visual Studio Version 16
VisualStudioVersion = 16.0.31025.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VmwareLauncher", "VmwareLauncher\VmwareLauncher.csproj", "{40A28143-CEF4-41B4-8476-3466822AAAA5}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VmwareLauncher", "VmwareLauncher\VmwareLauncher.csproj", "{89E29C69-15E2-43ED-9B98-4BFE9C6D7A2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,12 +11,15 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{40A28143-CEF4-41B4-8476-3466822AAAA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40A28143-CEF4-41B4-8476-3466822AAAA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40A28143-CEF4-41B4-8476-3466822AAAA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40A28143-CEF4-41B4-8476-3466822AAAA5}.Release|Any CPU.Build.0 = Release|Any CPU
{89E29C69-15E2-43ED-9B98-4BFE9C6D7A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{89E29C69-15E2-43ED-9B98-4BFE9C6D7A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89E29C69-15E2-43ED-9B98-4BFE9C6D7A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89E29C69-15E2-43ED-9B98-4BFE9C6D7A2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D877D8E5-8AB4-41AD-A601-EFBD24992B7E}
EndGlobalSection
EndGlobal
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
using System;
namespace VMwareLauncher
{
public static class ApplicationControl
{
public static void Shutdown(int exitCode)
{
switch (exitCode)
{
case 0:
Startup.trayIcon.ShowShutdownSuccessMessage();
break;
case -1:
Startup.trayIcon.WarnServiceShutdownFailure();
break;
default:
break;
}
Startup.trayIcon.Destroy();
Environment.Exit(exitCode);
}
}
}
+12 -14
View File
@@ -6,7 +6,7 @@ namespace VMwareLauncher
{
public class CheckDependencies
{
private BackgroundWorker performInitialChecks = new BackgroundWorker();
private readonly BackgroundWorker performInitialChecks = new BackgroundWorker();
public void PerformCheck()
{
@@ -14,22 +14,20 @@ namespace VMwareLauncher
if (!File.Exists(ProcessControl.DefaultVmwarePath))
{
MessageHandler.Show(MessageHandler.MessageCode.VmwareNotInstalled);
ApplicationControl.BlockingErrors = true;
ApplicationControl.Shutdown(-1);
}
// Determine if VML has ever run before.
string vmlPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\VmwareLauncher";
string vmlKey = "HasBeenSetup";
if (Registry.GetValue(vmlPath, vmlKey, null) == null)
else
{
Registry.SetValue(vmlPath, vmlKey, 1);
MessageHandler.Show(MessageHandler.MessageCode.WelcomeMessage);
}
// Determine if VML has ever run before.
string vmlPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\VmwareLauncher";
string vmlKey = "HasBeenSetup";
// Modify service status to manual.
ApplicationControl.BlockingErrors = Startup.serviceControl.ForceServicesManual();
if (Registry.GetValue(vmlPath, vmlKey, null) == null)
{
Registry.SetValue(vmlPath, vmlKey, 1);
MessageHandler.Show(MessageHandler.MessageCode.WelcomeMessage);
}
}
}
}
}
+6 -6
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -10,8 +7,11 @@ namespace VMwareLauncher
public class ProcessControl
{
public readonly static string DefaultVmwareExe = "vmware";
public readonly static string DefaultVmwarePath = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation", "InstallPath", null) + $"{DefaultVmwareExe}.exe";
public readonly static string DefaultVmlPath = "vmwarelauncher";
public readonly static string DefaultVmwarePath = (string) Microsoft.Win32.Registry.GetValue(
@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Workstation",
"InstallPath", null) +
$"{DefaultVmwareExe}.exe";
public readonly static string DefaultVmLauncherPath = "vmwarelauncher";
public string ProcessName { get; set; }
public void StartProcess()
+3 -3
View File
@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VMware Launcher")]
[assembly: AssemblyCopyright("Rebound Software - 2017")]
[assembly: AssemblyCopyright("Rebound Software - 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.0.9.7")]
[assembly: AssemblyFileVersion("2.0.9.7")]
+1 -11
View File
@@ -19,7 +19,7 @@ namespace VMwareLauncher.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -69,15 +69,5 @@ namespace VMwareLauncher.Properties {
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap VMwareWorkstationBack {
get {
object obj = ResourceManager.GetObject("VMwareWorkstationBack", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
-3
View File
@@ -121,7 +121,4 @@
<data name="VMwareLauncher" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\VMwareLauncher.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="VMwareWorkstationBack" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\VMwareWorkstationBack.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

+24 -5
View File
@@ -1,16 +1,20 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ServiceProcess;
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 static readonly List<string> VMwareServiceList = new List<string> //Array of services to close
{
"VMnetDHCP",
"VMUSBArbService",
"VMware NAT Service",
"VMwareHostd",
"VMAuthdService" };
public bool ForceServicesManual()
{
@@ -19,7 +23,7 @@ namespace VMwareLauncher
try
{
foreach (var service in ServiceList)
foreach (var service in VMwareServiceList)
{
string currentService = winServices + "\\" + service;
if ((int)Registry.GetValue(currentService, "Start", null) != 3)
@@ -36,5 +40,20 @@ namespace VMwareLauncher
return errors;
}
public List<string> GetStoppedVmServices()
{
var stoppedVmServices = new List<string>();
var services = ServiceController.GetServices();
foreach (var service in services)
{
if (service.Status == ServiceControllerStatus.Stopped &&
VMwareServiceList.Contains(service.ServiceName))
stoppedVmServices.Add(service.ServiceName);
}
return stoppedVmServices;
}
}
}
+8 -30
View File
@@ -1,5 +1,4 @@
using System;
using System.Windows;
using System.Windows;
namespace VMwareLauncher
{
@@ -9,7 +8,6 @@ namespace VMwareLauncher
public partial class Startup : Window
{
static internal TrayIcon trayIcon = new TrayIcon();
static internal ServiceControl serviceControl = new ServiceControl();
internal StatusWindow statusWindow = new StatusWindow();
internal CheckDependencies checkDependencies = new CheckDependencies();
@@ -17,44 +15,24 @@ namespace VMwareLauncher
{
InitializeComponent();
serviceControl.ServiceList = ServiceControl.DefaultVmwareServices;
ProcessControl vmWStationControl = new ProcessControl();
vmWStationControl.ProcessName = ProcessControl.DefaultVmwarePath;
ProcessControl vmwareControl = new ProcessControl();
vmwareControl.ProcessName = ProcessControl.DefaultVmwarePath;
ProcessControl vmLauncherControl = new ProcessControl();
vmLauncherControl.ProcessName = ProcessControl.DefaultVmLauncherPath;
ProcessControl vmlControl = new ProcessControl();
vmlControl.ProcessName = ProcessControl.DefaultVmlPath;
// Only continue if no errors have been detected.
checkDependencies.PerformCheck();
if (ApplicationControl.BlockingErrors)
ApplicationControl.Shutdown();
if (!vmlControl.IsProcessRunning())
if (!vmLauncherControl.IsProcessRunning())
{
statusWindow.Show();
trayIcon.Create();
}
else
{
vmwareControl.StartProcess();
ApplicationControl.Shutdown();
vmWStationControl.StartProcess();
ApplicationControl.Shutdown(0);
}
}
}
public static class ApplicationControl
{
public static bool BlockingErrors { get; set; }
public static void Shutdown()
{
Startup.trayIcon.Destroy();
if (BlockingErrors)
Environment.Exit(1);
else
Environment.Exit(0);
}
}
}
+7 -4
View File
@@ -5,11 +5,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VMwareLauncher"
mc:Ignorable="d"
Title="VMware Launcher 2.0" Height="173" Width="495" Loaded="Window_Loaded" ResizeMode="NoResize" Closing="Window_Closing" Icon="Resources/VMwareLauncher.ico">
Title="VMware Launcher 2.1" Height="202.5" Width="500" Loaded="Window_Loaded" ResizeMode="NoResize" Closing="Window_Closing" Icon="Resources/VMwareLauncher.ico">
<Grid>
<Image Stretch="Fill" Source="Resources/VMWareWorkstationBack.png"/>
<ProgressBar x:Name="progLoading" IsIndeterminate="True" Margin="0,0,0,6" Height="14" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="489"/>
<Label x:Name="labelStatus" Content="Starting VMware Workstation Services..." Margin="4,0,0,21" Foreground="#FFEAEAEA" FontFamily="Calibri" Height="25" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="470"/>
<Grid.Background>
<ImageBrush ImageSource="Resources/VMware-Logo.jpg" Stretch="UniformToFill"/>
</Grid.Background>
<ProgressBar x:Name="progLoading" IsIndeterminate="True" Margin="45,0,10,5" Height="14" VerticalAlignment="Bottom"/>
<Label x:Name="labelStatus" Content="Starting VMware Workstation Services..." Margin="40,0,-40,14" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" FontFamily="Calibri" Height="26" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="494"/>
</Grid>
</Window>
+40 -17
View File
@@ -16,6 +16,9 @@ namespace VMwareLauncher
BackgroundWorker runProcess = new BackgroundWorker();
BackgroundWorker loadServices = new BackgroundWorker();
BackgroundWorker stopServices = new BackgroundWorker();
BackgroundWorker forceServicesManual = new BackgroundWorker();
ServiceControl serviceControl = new ServiceControl();
public StatusWindow()
@@ -29,11 +32,23 @@ namespace VMwareLauncher
delayWindowHide.Tick += DelayWindowHide_Tick;
delayWindowHide.Interval = new TimeSpan(0, 0, 2);
forceServicesManual.DoWork += ForceServicesManual_DoWork;
runProcess.DoWork += RunProcess_DoWork;
loadServices.DoWork += LoadServices_DoWork;
stopServices.DoWork += StopServices_DoWork;
delayWindowHide.Start();
forceServicesManual.RunWorkerAsync();
}
private void ForceServicesManual_DoWork(object sender, DoWorkEventArgs e)
{
try
{
serviceControl.ForceServicesManual();
}
catch (Exception) { throw; }
loadServices.RunWorkerAsync();
}
@@ -46,7 +61,7 @@ namespace VMwareLauncher
{
try
{
foreach (string service in Startup.serviceControl.ServiceList)
foreach (string service in ServiceControl.VMwareServiceList)
{
ServiceController sc = new ServiceController(service, Environment.MachineName.ToString());
@@ -56,14 +71,25 @@ namespace VMwareLauncher
sc.WaitForStatus(ServiceControllerStatus.Stopped);
}
}
ApplicationControl.Shutdown();
// All 5 VMware Workstation services must be stopped to qualify
// a successful shutdown.
var stoppedVmServices = serviceControl.GetStoppedVmServices();
if (stoppedVmServices.Count != 5)
{
ApplicationControl.Shutdown(-1);
}
else
{
ApplicationControl.Shutdown(0);
}
}
catch (Exception) { throw; }
}
private void LoadServices_DoWork(object sender, DoWorkEventArgs e)
{
foreach (string service in Startup.serviceControl.ServiceList)
foreach (string service in ServiceControl.VMwareServiceList)
{
ServiceController sc = new ServiceController(service, Environment.MachineName.ToString());
@@ -85,23 +111,20 @@ namespace VMwareLauncher
private void RunProcess_DoWork(object sender, DoWorkEventArgs e)
{
if (!ApplicationControl.BlockingErrors)
ProcessControl processControl = new ProcessControl();
processControl.ProcessName = ProcessControl.DefaultVmwarePath;
processControl.StartProcess();
bool isVmwareRunning = true;
while (isVmwareRunning || TrayIcon.KeepLauncherRunning)
{
ProcessControl processControl = new ProcessControl();
processControl.ProcessName = ProcessControl.DefaultVmwarePath;
processControl.StartProcess();
Thread.Sleep(3000);
bool isVmwareRunning = true;
while (isVmwareRunning || TrayIcon.KeepLauncherRunning)
{
Thread.Sleep(3000);
isVmwareRunning = false; // Default value.
foreach (Process instance in Process.GetProcessesByName(ProcessControl.DefaultVmwareExe))
isVmwareRunning = true;
}
stopServices.RunWorkerAsync();
isVmwareRunning = false; // Default value.
foreach (Process instance in Process.GetProcessesByName(ProcessControl.DefaultVmwareExe))
isVmwareRunning = true;
}
stopServices.RunWorkerAsync();
}
/// <summary>
+14 -2
View File
@@ -69,12 +69,24 @@ namespace VMwareLauncher
}
}
public void Destroy()
public void WarnServiceShutdownFailure()
{
trayIcon.ShowBalloonTip(5000,
"VMware Launcher",
"VMware Launcher was unable to shutdown one or more Workstation services.",
ToolTipIcon.Warning);
}
public void ShowShutdownSuccessMessage()
{
trayIcon.ShowBalloonTip(3000,
"VMware Launcher",
"VMware Launcher has stopped all background Workstation services. Enjoy your day :-)",
ToolTipIcon.None);
ToolTipIcon.Info);
}
public void Destroy()
{
trayIcon.Dispose();
}
}
+5 -3
View File
@@ -15,7 +15,7 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@@ -64,6 +64,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ApplicationControl.cs" />
<Compile Include="CheckDependencies.cs" />
<Compile Include="ProcessControl.cs" />
<Compile Include="Properties\Resources.Designer.cs">
@@ -105,6 +106,7 @@
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="app.manifest" />
<None Include="Properties\Settings.settings">
@@ -118,10 +120,10 @@
</None>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\VMwareWorkstationBack.png" />
<Resource Include="Resources\VMwareLauncher.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\VMwareLauncher.ico" />
<Resource Include="Resources\VMware-Logo.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Binary file not shown.
Binary file not shown.