← Back to Home

Controlling Windows startup and shutdown behavior

Views: 909

You can try the commands on our interactive shell.

WindowsStartupShutdownBehavior

PowerShell スクリプトを使用して Windows の起動とシャットダウンを制御する

Windows の起動とシャットダウンは、システムの性能やセキュリティに影響を与えることがあります。PowerShell を使用して、Windows の startup と shutdown を制御することができます。

shutdown コマンドレット

shutdown コマンドレットは、Windows をシャットダウンするためのツールです。

shutdown /s /t 0

上記のコマンドは、Windows を即座にシャットダウンします。/s オプションでは、警告メッセージを表示せずにシャットダウンを行うことを示しています。

startup コマンドレット

startup コマンドレットは、Windows の起動を制御するためのツールです。

shutdown /r /t 0

上記のコマンドは、Windows をリブートします。/r オプションでは、システムをシャットダウンし、再起動を行うことを示しています。

PowerShell スクリプト

PowerShell スクリプトを使用して、Windows の startup と shutdown を制御することができます。

# Startup script
Start-Process -FilePath "C:\Path\To\Application.exe" -ArgumentList "-option"

# Shutdown script
Stop-Process -Name "explorer"

上記のスクリプトでは、Start-Process コマンドレットを使用して、アプリケーションを起動し、Stop-Process コマンドレットを使用して、エクスプローラーを止めることを示しています。

実行

PowerShell スクリプトを実行するには、PowerShell のインタープリターを使用します。

powershell -file "C:\Path\To\Script.ps1"

上記のコマンドでは、指定されたスクリプトを実行します。

参考文献**


Note: This is a translation of the original content, and it may not be entirely accurate or idiomatic in Japanese.

Try it Now!