Browse Source

set initial directory

Tobias Simetsreiter 4 years ago
parent
commit
ce06b1dcca

+ 2 - 1
WinImager/LibWinImager.psm1

@@ -12,7 +12,7 @@ $PSScriptRoot |Out-Host
 Function BecomeAdmin($script){
     if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))  
     {  
-        $arguments = "-ExecutionPolicy Bypass & '" +$env:WINIMAGER + "' -Script " + $script
+        $arguments = "-ExecutionPolicy RemoteSigned & '" +$env:WINIMAGER + "' -Script " + $script
 		Hide-Console
         Start-Process powershell -Wait -Verb runAs -ArgumentList $arguments
         Break
@@ -137,6 +137,7 @@ Function GuiSaveFileName
     )
     $SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
     $SaveFileDialog.initialDirectory = $initialDirectory
+    $SaveFileDialog.RestoreDirectory = $true
     $SaveFileDialog.filter = $filter + "|All files (*.*)| *.*"
     $SaveFileDialog.Title = $title
     $SaveFileDialog.ShowDialog() | Out-Null

+ 1 - 1
WinImager/WinImager.bat

@@ -1 +1 @@
-start powershell -ExecutionPolicy Bypass -File .\WinImager.ps1
+start powershell -ExecutionPolicy RemoteSigned -File .\WinImager.ps1

+ 5 - 1
WinImager/WinImager.ps1

@@ -9,7 +9,10 @@ while ($true){
 
     if ($Script -eq $null){
         $items = Get-ChildItem ([System.IO.Path]::Combine($PSScriptRoot,"bin"))
-        $items
+
+        "Included Scripts:"
+
+        $items | foreach {$_.Name}
 
         ""
 
@@ -34,6 +37,7 @@ while ($true){
     } catch {
         Write-Error $_.Exception | Tee-Object -FilePath $logpath -Append
         "An error Occurred. Save $logpath before continuing..."
+        GuiMessageBox "$_.Exception" -Buttons "Ok"
         pause
         Break
     }

+ 2 - 2
WinImager/bin/DiskToImage.ps1

@@ -21,8 +21,8 @@ Function Main()
 
         $filename = GuiSaveFileName
         $filename
-        if (($filename -eq $null) -or ($filename -eq "")){
-            Break
+        if ( -not $filename ){
+            Return
         }
 
         $dialog = @"

+ 2 - 2
WinImager/bin/ImageToDisk.ps1

@@ -14,8 +14,8 @@ Function Main()
     "Select Image File..."
     $filename = GuiOpenFileName
     $filename
-    if (($filename -eq $null) -or ($filename -eq "")){
-        Break
+    if ( -not $filename ){
+        Return
     }
     $continue = "Yes"
 

+ 1 - 2
WinImager/bin/ImageTruncate.ps1

@@ -16,7 +16,7 @@ Function Main()
     $size = $Lib.Wpf.ByteSizeDialog()
     if ( -not $size ){
         "No Size Selected"
-        Break
+        Return
     }
 
     "fsutil file seteof  $outfilename $size"
@@ -28,7 +28,6 @@ Function Main()
         GuiMessageBox "Error" -Buttons "Ok"
         pause
     }
-    Break
 }
 
 Main

+ 1 - 1
WinImager/bin/VBOX_ImageToVDI.ps1

@@ -18,7 +18,7 @@ Function Main()
     }
 
     "Select VDI File..."
-    $outfilename = $Lib.GuiSaveFileName("Output Virtualbox Image","Virtualbox Images (*.vdi)| *.vdi")
+    $outfilename = $Lib.GuiSaveFileName("Output Virtualbox Image","Virtualbox Images (*.vdi)| *.vdi", [io.path]GetDirectoyname($infilename))
 
     if (($outfilename -eq $null) -or ($outfilename -eq "")){
         "No Target Selected"

+ 1 - 1
WinImager/bin/VBOX_VDIToImage.ps1

@@ -29,7 +29,7 @@ Is VirtualBox installed?
 
     "Select Image File..."
     
-    $outname = GuiSaveFileName
+    $outname = GuiSaveFileName -InitialDirectory ([io.path]::GetDirectoryName($inname))
 
     if (($outname -eq $null) -or ($outname -eq "")){
         "No output file Selected"

+ 1 - 1
sfx/sfx_config.txt

@@ -1,4 +1,4 @@
 ;!@Install@!UTF-8!
 Title="WinImager"
-RunProgram="powershell.exe -ExecutionPolicy Bypass %%T\WinImager\WinImager.ps1"
+RunProgram="powershell.exe -ExecutionPolicy RemoteSigned %%T\WinImager\WinImager.ps1"
 ;!@InstallEnd@!