Parcourir la source

add VDICompact

Tobias Simetsreiter il y a 4 ans
Parent
commit
5058abb48b
4 fichiers modifiés avec 75 ajouts et 1 suppressions
  1. 3 0
      Makefile
  2. 31 0
      WinImager/bin/ImageTruncate.ps1
  3. 40 0
      WinImager/bin/VDICompact.ps1
  4. 1 1
      WinImager/bin/VDIToImage.ps1

+ 3 - 0
Makefile

@@ -5,3 +5,6 @@ build:
 	rm -f dist/WinImager.7z
 	7z a dist/WinImager.7z WinImager
 	cat sfx/7zsd_All_x64.sfx  sfx/sfx_config.txt dist/WinImager.7z > dist/WinImager.exe
+
+run: 
+	start dist/WinImager.exe

+ 31 - 0
WinImager/bin/ImageTruncate.ps1

@@ -0,0 +1,31 @@
+
+Import-Module -Name $env:PSLIB
+
+Function Main()
+{
+    
+    "Select Image File..."
+    
+    $outfilename = GuiSaveFileName
+
+    if (($outfilename -eq $null) -or ($outfilename -eq "")){
+        "No Target Selected"
+        Break
+    }
+
+    if (Test-Path $outfilename -PathType Leaf) {
+        Remove-Item $outfilename
+    }
+
+    fsutil file seteof  .\FB_small.img ([Math]::Pow(2,2))
+
+    if($LASTEXITCODE -eq 0){
+        GuiMessageBox "Success" -Buttons "Ok"
+    } else {
+        GuiMessageBox "Error" -Buttons "Ok"
+    }
+    Break
+}
+
+Main
+

+ 40 - 0
WinImager/bin/VDICompact.ps1

@@ -0,0 +1,40 @@
+
+Import-Module -Name $env:PSLIB
+
+Function Main()
+{
+    if ($env:VBOX_INSTALL_PATH -ne $null){
+        $VBOXMANAGE = $env:VBOX_INSTALL_PATH + "VBoxManage.exe"
+    } elseif ($env:VBOX_MSI_INSTALL_PATH -ne $null){
+        $VBOXMANAGE = $env:VBOX_MSI_INSTALL_PATH + "VBoxManage.exe"
+    } else {
+        $dialog = @"
+VirtualBox install Path not found!
+
+Is VirtualBox installed?
+"@ 
+        $dialog
+        GuiMessageBox $dialog -Buttons "Ok"
+        Break
+    }
+    
+    "Select VDI File..."
+
+    $inname = GuiOpenFileName -Filter "Virtualbox Images (*.vdi)| *.vdi"
+
+    if (($inname -eq $null) -or ($inname -eq "")){
+        "No input file selected"
+        Break
+    }
+
+    &$VBOXMANAGE modifymedium disk $inname --compact
+
+    if($LASTEXITCODE -eq 0){
+        GuiMessageBox "Success" -Buttons "Ok"
+    } else {
+        GuiMessageBox "Error" -Buttons "Ok"
+    }
+    Break
+}
+
+Main

+ 1 - 1
WinImager/bin/VDIToImage.ps1

@@ -43,7 +43,7 @@ Is VirtualBox installed?
 
     &$VBOXMANAGE clonehd $inname  $outname --format RAW
 
-    if($LASTEXITCODE -ne 0){
+    if($LASTEXITCODE -eq 0){
         GuiMessageBox "Success" -Buttons "Ok"
     } else {
         GuiMessageBox "Error" -Buttons "Ok"