Skip to content

Commit e744080

Browse files
authored
Merge pull request #48 from 0xf005ba11/check-vsms
check virtual system management earlier
2 parents b5c3f58 + 99f223a commit e744080

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

VMPlex/App.xaml.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Diagnostics;
33
using System.IO;
44
using System.Windows;
5+
using EasyWMI;
6+
using HyperV;
57
using IWshRuntimeLibrary;
68
using Microsoft.Win32;
79

@@ -15,13 +17,33 @@ public partial class App : Application
1517
protected override void OnStartup(StartupEventArgs e)
1618
{
1719
HandleCommandLine();
20+
CheckCapability();
1821
LoadUserSettings();
1922
Utility.TryExtractHVIntegrate();
2023
base.OnStartup(e);
2124
Utility.CreateSelfJob();
2225
}
2326

24-
private void LoadUserSettings()
27+
static private void CheckCapability()
28+
{
29+
//
30+
// Before we show any other windows check that we can access the
31+
// management service, if we can't then exit.
32+
//
33+
var vsms = new WmiScope(@"root\virtualization\v2")
34+
.GetInstance<IMsvm_VirtualSystemManagementService>();
35+
if (vsms == null)
36+
{
37+
UI.MessageBox.Show(
38+
System.Windows.MessageBoxImage.Error,
39+
"Virtual System Management",
40+
"VMPlex is unable to interact with the Virtual Machine Management Service. " +
41+
"Please run as administrator or add your user to the Hyper-V Administrators group.");
42+
Environment.Exit(0xdead);
43+
}
44+
}
45+
46+
static private void LoadUserSettings()
2547
{
2648
try
2749
{

VMPlex/VMManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ private VMManager()
199199
{
200200
UI.MessageBox.Show(
201201
System.Windows.MessageBoxImage.Error,
202-
"Vrtual System Management",
203-
"VMPlex is unable to interact with the Virtual Machine Management Service. Please run as administrator or add your user to the Hyper-V Administrators group.");
202+
"Virtual System Management",
203+
"VMPlex is unable to interact with the Virtual Machine Management Service. " +
204+
"Please run as administrator or add your user to the Hyper-V Administrators group.");
204205
Environment.Exit(0xdead);
205206
}
206207

0 commit comments

Comments
 (0)