0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShellのPause方法についての備忘録

Last updated at Posted at 2020-04-21

PowerShellにはDOSコマンドのPAUSEにあたるコマンドレットがないため
自分で実装する必要があります

$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")で実現はできるのですが
この場合PowerShell ISE上から実行した場合、エラーが発生するので注意が必要です

pause.ps1
    if ($psISE)
    {
        Add-Type -AssemblyName System.Windows.Forms
        [System.Windows.Forms.MessageBox]::Show("")
    }
    else
    {
        $x = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
    }

参考

Stack Overflow - Press any key to continue [duplicate]

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?