Skip to content

Instantly share code, notes, and snippets.

@Youka
Created September 10, 2017 13:26
Show Gist options
  • Select an option

  • Save Youka/46f93ffb0dc98087dc461742b12b9e8e to your computer and use it in GitHub Desktop.

Select an option

Save Youka/46f93ffb0dc98087dc461742b12b9e8e to your computer and use it in GitHub Desktop.
Powershell process hides console in background
# Hide console
Add-Type -Namespace User32 -Name Functions -MemberDefinition @"
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
"@
[User32.Functions]::ShowWindowAsync((Get-Process -Id $pid).MainWindowHandle, 0)
# Register form objects from .NET
[void][reflection.assembly]::loadwithpartialname("System.Windows.Forms")
# Create & show simple dialog
(New-Object system.Windows.Forms.Form).showdialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment