Created
December 17, 2015 17:28
-
-
Save advanceboy/9c78ed7c7d82c94b0f52 to your computer and use it in GitHub Desktop.
Win32 API を呼び出して、 PowerShell のコンソールウィンドウを隠すテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start /MIN powershell -File "%~dpn0.ps1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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