Skip to content

Instantly share code, notes, and snippets.

@advanceboy
Created December 17, 2015 17:28
Show Gist options
  • Save advanceboy/9c78ed7c7d82c94b0f52 to your computer and use it in GitHub Desktop.
Save advanceboy/9c78ed7c7d82c94b0f52 to your computer and use it in GitHub Desktop.
Win32 API を呼び出して、 PowerShell のコンソールウィンドウを隠すテスト
start /MIN powershell -File "%~dpn0.ps1"
# Hide Window
$asyncwindowType = Add-Type -Name Win32ShowWindowAsync -Namespace Win32Functions -PassThru -MemberDefinition '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);';
$null = $asyncwindowType::ShowWindowAsync((Get-Process -PID $pid).MainWindowHandle, 0 <# SW_HIDE #>);
# Show MsgBox
Start-Sleep 1;
Add-Type -AssemblyName System.Windows.Forms;
$null = [System.Windows.Forms.MessageBox]::Show("Hello World");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment