diff --git a/App.config b/App.config
new file mode 100644
index 0000000..a60a675
--- /dev/null
+++ b/App.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/App.xaml b/App.xaml
new file mode 100644
index 0000000..4d3a5bd
--- /dev/null
+++ b/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
new file mode 100644
index 0000000..b55b970
--- /dev/null
+++ b/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace VBoxManageUI
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/MainWindow.xaml b/MainWindow.xaml
new file mode 100644
index 0000000..5faea81
--- /dev/null
+++ b/MainWindow.xaml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
new file mode 100644
index 0000000..e651eb3
--- /dev/null
+++ b/MainWindow.xaml.cs
@@ -0,0 +1,119 @@
+using System.Collections.Generic;
+using System.Configuration;
+using System.Diagnostics;
+using System.Windows;
+
+namespace VBoxManageUI
+{
+ public partial class MainWindow : Window
+ {
+ public List HDDs { get; set; } = new List();
+ public MainWindow()
+ {
+ DataContext = this;
+ InitializeComponent();
+ ListHdd();
+ }
+ public void ListHdd()
+ {
+ var vbox_exe = ConfigurationManager.AppSettings["VBoxManagePath"];
+ var vbox_process = Process.Start(new ProcessStartInfo(vbox_exe, "list hdds")
+ {
+ UseShellExecute = false,
+ RedirectStandardOutput = true,
+ CreateNoWindow = true
+ });
+ const string UUID = "UUID";
+ const string ParentUUID = "Parent UUID";
+ const string State = "State";
+ const string Type = "Type";
+ const string Location = "Location";
+ const string Format = "Storage format";
+ const string Capacity = "Capacity";
+ const string Encryption = "Encryption";
+ HDDs.Clear();
+ VBoxHdd hdd = null;
+ while (!vbox_process.StandardOutput.EndOfStream)
+ {
+ string line = vbox_process.StandardOutput.ReadLine();
+ if (line.StartsWith(UUID))
+ {
+ hdd = new VBoxHdd();
+ hdd.UUID = line.Substring(UUID.Length + 1).Trim();
+ }
+ if (line.StartsWith(ParentUUID))
+ {
+ hdd.ParentUUID = line.Substring(ParentUUID.Length + 1).Trim();
+ }
+ if (line.StartsWith(State))
+ {
+ hdd.State = line.Substring(State.Length + 1).Trim();
+ }
+ if (line.StartsWith(Type))
+ {
+ hdd.Type = line.Substring(Type.Length + 1).Trim();
+ }
+ if (line.StartsWith(Location))
+ {
+ hdd.Location = line.Substring(Location.Length + 1).Trim();
+ }
+ if (line.StartsWith(Format))
+ {
+ hdd.Format = line.Substring(Format.Length + 1).Trim();
+ }
+ if (line.StartsWith(Capacity))
+ {
+ hdd.Capacity = line.Substring(Capacity.Length + 1).Trim();
+ }
+ if (line.StartsWith(Encryption))
+ {
+ hdd.Encryption = line.Substring(Encryption.Length + 1).Trim();
+ HDDs.Add(hdd);
+ }
+ }
+ DataContext = null;
+ DataContext = this;
+ }
+ void btnList_Click(object sender, RoutedEventArgs e)
+ {
+ ListHdd();
+ }
+ void dg_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
+ {
+ if (dg.SelectedItem != null)
+ {
+ btnCompact.IsEnabled = true;
+ }
+ else
+ {
+ btnCompact.IsEnabled = false;
+ }
+ }
+ void btnCompact_Click(object sender, RoutedEventArgs e)
+ {
+ var hdd = dg.SelectedItem as VBoxHdd;
+ if (hdd==null)
+ {
+ return;
+ }
+ if (hdd.Format != "VDI")
+ {
+ MessageBox.Show("Compacting is currently only available for VDI images");
+ return;
+ }
+ if (hdd.State.StartsWith("locked"))
+ {
+ MessageBox.Show("Hard Drive is currently locked");
+ return;
+ }
+ var vbox_exe = ConfigurationManager.AppSettings["VBoxManagePath"];
+ var vbox_process = Process.Start(vbox_exe, $"modifyhd {hdd.UUID} --compact");
+ vbox_process.WaitForExit();
+ MessageBox.Show($"Done. Exit Code {vbox_process.ExitCode}.");
+ }
+ void btnHelp_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show("Please Defragment and Zero (ex. \"sdelete.exe c: -z\") your virtual hard drive before compacting it.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..91c36ab
--- /dev/null
+++ b/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("VBoxManageUI")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("VBoxManageUI")]
+[assembly: AssemblyCopyright("Copyright © 2023")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// 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("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..b3da885
--- /dev/null
+++ b/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace VBoxManageUI.Properties
+{
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // 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.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VBoxManageUI.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..0dd68f0
--- /dev/null
+++ b/Properties/Settings.Designer.cs
@@ -0,0 +1,35 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace VBoxManageUI.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe")]
+ public string VBoxManagePath {
+ get {
+ return ((string)(this["VBoxManagePath"]));
+ }
+ }
+ }
+}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
new file mode 100644
index 0000000..64b5365
--- /dev/null
+++ b/Properties/Settings.settings
@@ -0,0 +1,9 @@
+
+
+
+
+
+ C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index d1f34ed..ac35bbd 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,14 @@
# VBoxManageUI
Simple User Interface for VirtualBox VBoxManage CLI utility
+
+This utility compact virtual disks in an easy way, to save a lot of disk space.
+
+![alt text](docs/screen.png)
+
+Before running this utility ensure that:
+- The virtual disk is defragmented
+- The virtual disk free space is zeroed
+
+To zero free space run [sdelete](https://learn.microsoft.com/en-us/sysinternals/downloads/sdelete), for example "sdelete.exe c: -z" where C: is your data partition
+
+If your Virtual Box installation is different from "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe", please update the "VBoxManagePath" key in the "VBoxManageUI.exe.config" file, before running the utility.
\ No newline at end of file
diff --git a/VBoxHdd.cs b/VBoxHdd.cs
new file mode 100644
index 0000000..97f5054
--- /dev/null
+++ b/VBoxHdd.cs
@@ -0,0 +1,14 @@
+namespace VBoxManageUI
+{
+ public class VBoxHdd
+ {
+ public string UUID { get; set; }
+ public string ParentUUID { get; set; }
+ public string State { get; set; }
+ public string Type { get; set; }
+ public string Location { get; set; }
+ public string Format { get; set; }
+ public string Capacity { get; set; }
+ public string Encryption { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/VBoxManageUI.csproj b/VBoxManageUI.csproj
new file mode 100644
index 0000000..4f0a8ce
--- /dev/null
+++ b/VBoxManageUI.csproj
@@ -0,0 +1,105 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {4082CE06-0FE6-44B6-925D-4C46C24DE4FD}
+ WinExe
+ VBoxManageUI
+ VBoxManageUI
+ v4.8
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VBoxManageUI.sln b/VBoxManageUI.sln
new file mode 100644
index 0000000..49100d4
--- /dev/null
+++ b/VBoxManageUI.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.6.33815.320
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBoxManageUI", "VBoxManageUI.csproj", "{4082CE06-0FE6-44B6-925D-4C46C24DE4FD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4082CE06-0FE6-44B6-925D-4C46C24DE4FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4082CE06-0FE6-44B6-925D-4C46C24DE4FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4082CE06-0FE6-44B6-925D-4C46C24DE4FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4082CE06-0FE6-44B6-925D-4C46C24DE4FD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {EA91E736-3D36-462C-91B9-4784031397BC}
+ EndGlobalSection
+EndGlobal
diff --git a/docs/screen.png b/docs/screen.png
new file mode 100644
index 0000000..0c86ccb
Binary files /dev/null and b/docs/screen.png differ