简体   繁体   中英

Hide or Minimize the powershell prompt after Winform Launch

I have written a simple powershell script to launch a winform(Winform code written within powershell script for example showContent.ps1 file) & showing some content. I need to hide the powershell.exe command prompt after the launch of the Winform.

After searching some cases in web, I tried below Scenario: 1)I tried to execute " powershell.exe -Command -windowstyle Hidden " in the start of the script file "showContent.ps1"

2) Created a new script file exa:LaunchWinForm.ps1 and in that mentioned the command as: PowerShell.exe -windowstyle Hidden showContent.ps1

It is not working.

I am using Powershell 3.0

Could anyone tell what is going wrong or suggest any way to do it.

在您创建的新的单独脚本文件中,试试这个:

powershell.exe -WindowStyle Hidden -File "c:\path\to the\GUI_Script.ps1"

This solution Minimizes Powershell window after it starts. Powershell window opens, then disapears, without using any outside code. I put at beginning of my scripts, but sounds like you want to put the code after you open your form.

$t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
add-type -name win -member $t -namespace native
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM