Tutorial | Gaming | Vloging

Teknologi masa depan

Teknologi adalah hal yang tidak asing lagi pada zaman now.

Smart Handphone

Ya, dengan handphone bisa menjelajah dunia maya hanya dengan genggaman.

Geek electronics resistors transistors

Best geek electronics resistors transistors.

Kualitas Terbaik Mobile and Website

Best Quality Mobile and Website

Bagaimana cara mengambil alih bisnis

Anda memilih untuk mengambil alih bisnis daripada membuat toko sendiri? Ini mungkin, tetapi prasyarat diperlukan. Sudah, perlu untuk melakukan studi mendalam tentang proyek yang ada. Selain itu, untuk menetapkan tujuan pribadi seseorang diperlukan.

Kamis, 02 Oktober 2025

Script Auto Shutdown PC With Power Shell & Bat File

PPowerShell Script (Save as ShutdownPC.ps1)

powershell
# Shutdown PC script Stop-Computer -Force

How to Run It

  1. Open PowerShell as Administrator (right-click Start > Windows PowerShell (Admin)).
  2. Navigate to the script's directory: cd "C:\Path\To\Your\Script".
  3. Execute: .\ShutdownPC.ps1.

One-Liner Alternative

If you just want to run it directly in PowerShell (as Admin):

powershell
Stop-Computer -Force

For a delayed shutdown (e.g., 30 seconds), use:

powershell
Stop-Computer -Force -Wait -For PowerOff -Timeout 30

If you need to restart instead, replace with Restart-Computer -Force.

shutdown pc with run bat

BLACKBOXAI

Here's a simple Windows batch file (.bat) script to shut down your PC immediately. Warning: This will force a shutdown without saving open files or prompting for confirmation. Run it only if you're sure, and test on a non-critical machine if possible.

Batch Script (Save as ShutdownPC.bat)

Create a new text file, paste the following code, and save it with a .bat extension (e.g., ShutdownPC.bat):

batch
@echo off echo Shutting down PC in 5 seconds... Press Ctrl+C to cancel. timeout /t 5 /nobreak >nul shutdown /s /f /t 0
  • /s: Shuts down the PC.
  • /f: Forces running applications to close.
  • /t 0: Sets the timeout to 0 seconds (immediate after the delay).
  • The timeout adds a 5-second grace period for you to cancel (press Ctrl+C).

How to Run It

  1. Save the file to a convenient location (e.g., Desktop).
  2. Right-click the .bat file and select Run as administrator (important for shutdown privileges).
    • Or, open Command Prompt as Administrator (right-click Start > Command Prompt (Admin) or Terminal (Admin)), navigate to the file's directory with cd "C:\Path\To\Your\Script", and run ShutdownPC.bat.

One-Liner Alternative

If you just want to run it directly in Command Prompt (as Admin) without a file:

cmd
shutdown /s /f /t 0

Variations

  • Delayed Shutdown (e.g., 30 seconds, with cancel option):

    batch
    @echo off shutdown /s /f /t 30 echo PC will shut down in 30 seconds. To cancel, run: shutdown /a
    • To cancel a pending shutdown: Open Command Prompt as Admin and run shutdown /a.
  • Restart Instead: Replace /s with /r in the command (e.g., shutdown /r /f /t 0).

If you're on a different OS (e.g., Linux/Mac), let me know for alternatives. Always back up important work before using shutdown scripts!

Share:

Translate

English French German Spain Italian Dutch

Russian Portuguese Japanese Korean Arabic Chinese Simplified

Label

Visitor

Labels