|
|
@@ -5,7 +5,8 @@ Function BecomeAdmin($invocation){
|
|
|
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
|
|
|
{
|
|
|
$arguments = "-ExecutionPolicy Bypass & '" +$invocation.mycommand.definition + "'"
|
|
|
- Start-Process powershell -Verb runAs -ArgumentList $arguments
|
|
|
+ Hide-Console
|
|
|
+ Start-Process powershell -Wait -Verb runAs -ArgumentList $arguments
|
|
|
Break
|
|
|
}
|
|
|
}
|
|
|
@@ -15,17 +16,17 @@ Function LogFilePath($invocation,$name){
|
|
|
[System.IO.Path]::Combine($invocation.MyCommand.Definition, "..", "..","log", $logfilename)
|
|
|
}
|
|
|
|
|
|
-Function AskContinue($text)
|
|
|
+Function GuiMessageBox
|
|
|
{
|
|
|
- [System.Windows.Forms.MessageBox]::Show($text, 'Continue','YesNo','Info')
|
|
|
-}
|
|
|
-
|
|
|
-Function MessageBox($text)
|
|
|
-{
|
|
|
- [System.Windows.Forms.MessageBox]::Show($text, 'Continue','YesNo','Info')
|
|
|
+ param(
|
|
|
+ $text,
|
|
|
+ $title = "Continue",
|
|
|
+ $buttons = "YesNo",
|
|
|
+ $level = "Info"
|
|
|
+ )
|
|
|
+ [System.Windows.Forms.MessageBox]::Show($text, $title, $buttons, $level)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
Function WinDD($inFileName, $outFileName, $bs = 5Mb, $create = $false) {
|
|
|
|
|
|
Write-Output ""
|
|
|
@@ -130,11 +131,16 @@ y
|
|
|
|
|
|
}
|
|
|
|
|
|
-Function GuiSaveFileName($initialDirectory = "C:\", $title = "Save Image File")
|
|
|
+Function GuiSaveFileName
|
|
|
{
|
|
|
+ param(
|
|
|
+ $initialDirectory = "C:\",
|
|
|
+ $title = "Save Image File",
|
|
|
+ $filter = "Images (*.img;*.afp;*.usb;*.iso)| *.img;*.afp;*.usb;*.iso"
|
|
|
+ )
|
|
|
$SaveFileDialog = New-Object System.Windows.Forms.SaveFileDialog
|
|
|
$SaveFileDialog.initialDirectory = $initialDirectory
|
|
|
- $SaveFileDialog.filter = "Images (*.img;*.afp;*.usb;*.iso)| *.img;*.afp;*.usb;*.iso|All files (*.*)| *.*"
|
|
|
+ $SaveFileDialog.filter = $filter + "|All files (*.*)| *.*"
|
|
|
$SaveFileDialog.Title = $title
|
|
|
$SaveFileDialog.ShowDialog() | Out-Null
|
|
|
$SaveFileDialog.filename
|
|
|
@@ -242,4 +248,41 @@ Function GuiDiskLabel(){
|
|
|
("{0,-3} {1,-4} {2,-22} {3,-20} {4,8} GB" -f $number,$bustype,$name,$serial,$size)
|
|
|
}
|
|
|
|
|
|
+# .Net methods for hiding/showing the console in the background
|
|
|
+Add-Type -Name Window -Namespace Console -MemberDefinition '
|
|
|
+[DllImport("Kernel32.dll")]
|
|
|
+public static extern IntPtr GetConsoleWindow();
|
|
|
+
|
|
|
+[DllImport("user32.dll")]
|
|
|
+public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
|
|
+'
|
|
|
+
|
|
|
+function Show-Console
|
|
|
+{
|
|
|
+ $consolePtr = [Console.Window]::GetConsoleWindow()
|
|
|
+
|
|
|
+ # Hide = 0,
|
|
|
+ # ShowNormal = 1,
|
|
|
+ # ShowMinimized = 2,
|
|
|
+ # ShowMaximized = 3,
|
|
|
+ # Maximize = 3,
|
|
|
+ # ShowNormalNoActivate = 4,
|
|
|
+ # Show = 5,
|
|
|
+ # Minimize = 6,
|
|
|
+ # ShowMinNoActivate = 7,
|
|
|
+ # ShowNoActivate = 8,
|
|
|
+ # Restore = 9,
|
|
|
+ # ShowDefault = 10,
|
|
|
+ # ForceMinimized = 11
|
|
|
+
|
|
|
+ [Console.Window]::ShowWindow($consolePtr, 4)
|
|
|
+}
|
|
|
+
|
|
|
+function Hide-Console
|
|
|
+{
|
|
|
+ $consolePtr = [Console.Window]::GetConsoleWindow()
|
|
|
+ #0 hide
|
|
|
+ [Console.Window]::ShowWindow($consolePtr, 0)
|
|
|
+}
|
|
|
+
|
|
|
Export-ModuleMember -Function *
|