[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.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -6,6 +6,18 @@ namespace VMwareLauncher
|
|||||||
{
|
{
|
||||||
public static void Shutdown(int exitCode)
|
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();
|
Startup.trayIcon.Destroy();
|
||||||
Environment.Exit(exitCode);
|
Environment.Exit(exitCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,5 +51,5 @@ using System.Windows;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.0.9.6")]
|
[assembly: AssemblyVersion("2.0.9.7")]
|
||||||
[assembly: AssemblyFileVersion("2.0.9.6")]
|
[assembly: AssemblyFileVersion("2.0.9.7")]
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ServiceProcess;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace VMwareLauncher
|
namespace VMwareLauncher
|
||||||
{
|
{
|
||||||
@@ -38,5 +40,20 @@ namespace VMwareLauncher
|
|||||||
|
|
||||||
return errors;
|
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,7 +8,6 @@ namespace VMwareLauncher
|
|||||||
public partial class Startup : Window
|
public partial class Startup : Window
|
||||||
{
|
{
|
||||||
static internal TrayIcon trayIcon = new TrayIcon();
|
static internal TrayIcon trayIcon = new TrayIcon();
|
||||||
static internal ServiceControl serviceControl = new ServiceControl();
|
|
||||||
internal StatusWindow statusWindow = new StatusWindow();
|
internal StatusWindow statusWindow = new StatusWindow();
|
||||||
internal CheckDependencies checkDependencies = new CheckDependencies();
|
internal CheckDependencies checkDependencies = new CheckDependencies();
|
||||||
|
|
||||||
@@ -24,9 +23,6 @@ namespace VMwareLauncher
|
|||||||
|
|
||||||
checkDependencies.PerformCheck();
|
checkDependencies.PerformCheck();
|
||||||
|
|
||||||
// Modify service status to manual.
|
|
||||||
serviceControl.ForceServicesManual();
|
|
||||||
|
|
||||||
if (!vmLauncherControl.IsProcessRunning())
|
if (!vmLauncherControl.IsProcessRunning())
|
||||||
{
|
{
|
||||||
statusWindow.Show();
|
statusWindow.Show();
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ namespace VMwareLauncher
|
|||||||
BackgroundWorker runProcess = new BackgroundWorker();
|
BackgroundWorker runProcess = new BackgroundWorker();
|
||||||
BackgroundWorker loadServices = new BackgroundWorker();
|
BackgroundWorker loadServices = new BackgroundWorker();
|
||||||
BackgroundWorker stopServices = new BackgroundWorker();
|
BackgroundWorker stopServices = new BackgroundWorker();
|
||||||
|
BackgroundWorker forceServicesManual = new BackgroundWorker();
|
||||||
|
|
||||||
|
ServiceControl serviceControl = new ServiceControl();
|
||||||
|
|
||||||
|
|
||||||
public StatusWindow()
|
public StatusWindow()
|
||||||
@@ -29,11 +32,23 @@ namespace VMwareLauncher
|
|||||||
delayWindowHide.Tick += DelayWindowHide_Tick;
|
delayWindowHide.Tick += DelayWindowHide_Tick;
|
||||||
delayWindowHide.Interval = new TimeSpan(0, 0, 2);
|
delayWindowHide.Interval = new TimeSpan(0, 0, 2);
|
||||||
|
|
||||||
|
forceServicesManual.DoWork += ForceServicesManual_DoWork;
|
||||||
runProcess.DoWork += RunProcess_DoWork;
|
runProcess.DoWork += RunProcess_DoWork;
|
||||||
loadServices.DoWork += LoadServices_DoWork;
|
loadServices.DoWork += LoadServices_DoWork;
|
||||||
stopServices.DoWork += StopServices_DoWork;
|
stopServices.DoWork += StopServices_DoWork;
|
||||||
|
|
||||||
delayWindowHide.Start();
|
delayWindowHide.Start();
|
||||||
|
forceServicesManual.RunWorkerAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ForceServicesManual_DoWork(object sender, DoWorkEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
serviceControl.ForceServicesManual();
|
||||||
|
}
|
||||||
|
catch (Exception) { throw; }
|
||||||
|
|
||||||
loadServices.RunWorkerAsync();
|
loadServices.RunWorkerAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,8 +71,19 @@ namespace VMwareLauncher
|
|||||||
sc.WaitForStatus(ServiceControllerStatus.Stopped);
|
sc.WaitForStatus(ServiceControllerStatus.Stopped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
ApplicationControl.Shutdown(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception) { throw; }
|
catch (Exception) { throw; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
trayIcon.ShowBalloonTip(3000,
|
||||||
"VMware Launcher",
|
"VMware Launcher",
|
||||||
"VMware Launcher has stopped all background Workstation services. Enjoy your day :-)",
|
"VMware Launcher has stopped all background Workstation services. Enjoy your day :-)",
|
||||||
ToolTipIcon.None);
|
ToolTipIcon.Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Destroy()
|
||||||
|
{
|
||||||
trayIcon.Dispose();
|
trayIcon.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user