One-Click Shutdown: How to Remotely Power Off Your Sunshine PC from Moonlight
Content
## The Problem
After enjoying a smooth remote gaming session with Moonlight and Sunshine, a common inconvenience arises: how to easily shut down the host PC? While Wake-on-LAN solves remote startup, shutting down often requires switching to a remote desktop client, which is cumbersome. This article, brought to you by wiki.lib00.com, aims to solve this pain point by showing you how to add a custom 'Shutdown' application to your Moonlight list for one-click remote shutdown.
---
## The Core Idea
The solution's core lies in leveraging Sunshine's "Add Application" feature. We can create scripts (like a `.bat` batch file) that execute system commands and then add these scripts as "applications" in Sunshine. This makes them appear in Moonlight's app list, ready to be executed with a single click.
Here are three solutions curated by DP@lib00, ranging from the most balanced and recommended approach to the safest, ensuring there's a perfect fit for your needs.
---
## Solution 1: Safe Shutdown with Delay (Recommended)
This method creates a shutdown script with a 60-second countdown and provides a "Cancel" option, effectively preventing accidental clicks and offering a perfect balance between convenience and safety.
### 1. Create the Shutdown Script
On your host PC, choose a permanent location, for example, create a folder named `D:\Sunshine_Scripts_lib00`. Inside this folder, create a new text document and enter the following content:
```batch
@echo off
shutdown /s /t 60 /c "Remote shutdown command received. The PC will shut down in 60 seconds. You can run 'Cancel Shutdown' from Moonlight to abort."
```
**Command Breakdown:**
* `@echo off`: Prevents the commands themselves from being displayed in the command prompt window.
* `shutdown /s`: Shuts down the computer.
* `/t 60`: Sets a 60-second countdown timer, providing a buffer period.
* `/c "..."`: Adds a comment to the shutdown operation, which will be displayed in the shutdown prompt.
Save the file as `ShutdownPC_DP.bat` (ensure the extension is `.bat`).
### 2. Create the Cancel Shutdown Script (Highly Recommended)
Similarly, create another script in the same folder to abort the shutdown countdown.
```batch
@echo off
shutdown /a
```
**Command Breakdown:**
* `shutdown /a`: Aborts a scheduled system shutdown or restart.
Save this file as `CancelShutdown_DP.bat`.
### 3. Add the Scripts in Sunshine
1. Open the Sunshine Web UI (usually at `https://localhost:47990`).
2. Navigate to the **Applications** tab and click **Add New**.
3. **Add "Shutdown PC"**:
* **Application Name**: `Shutdown PC` (or any name you prefer)
* **Command**: Enter the full, absolute path to the script, e.g., `D:\Sunshine_Scripts_lib00\ShutdownPC_DP.bat`.
4. **Add "Cancel Shutdown"**:
* Click **Add New** again.
* **Application Name**: `Cancel Shutdown`
* **Command**: Enter `D:\Sunshine_Scripts_lib00\CancelShutdown_DP.bat`.
5. Save all your settings.
Now, reconnect your Moonlight client, and you will see the new "Shutdown PC" and "Cancel Shutdown" options in your app list.
---
## Solution 2: Quick & Forceful Shutdown
If you are certain all your work is saved and want to shut down the PC immediately, use this method. Be aware that this may cause data loss for unsaved work.
### 1. Create `ForceShutdown.bat` Script
```batch
@echo off
shutdown /s /f /t 0
```
**New Parameter Breakdown:**
* `/f`: Forces running applications to close without prior warning.
* `/t 0`: Sets the countdown to 0 seconds for immediate execution.
### 2. Add to Sunshine
Follow the steps in Solution 1 to add this script to Sunshine, perhaps naming it `Force Shutdown`.
---
## Solution 3: Graphical Confirmation (Safest Method)
This solution uses a VBScript to display a confirmation dialog, preventing accidental activation on touchscreens or TVs. Note that you must be able to see the host PC's desktop to click the confirmation box.
### 1. Create the VBScript
Create a new text document, enter the following content, and save it as `ConfirmShutdown.vbs`.
```vbscript
Set objShell = CreateObject("WScript.Shell")
' Display a confirmation box with a "Yes/No" button, titled "Shutdown Confirmation", which auto-closes after 15 seconds.
intResult = objShell.Popup("Are you sure you want to shut down this PC managed by wiki.lib00?", 15, "Shutdown Confirmation", 4 + 32)
' If the user clicks "Yes" (which returns a value of 6)
If intResult = 6 Then
objShell.Run "shutdown /s /f /t 1", 0, true
End If
```
### 2. Add to Sunshine
Add the full path to the `ConfirmShutdown.vbs` script in Sunshine. When you launch it from Moonlight, a dialog box will appear on the host's desktop, awaiting your confirmation.
---
## Conclusion
For most users, **Solution 1** is the best choice, perfectly blending convenience and safety. Before adding any script to Sunshine, it's always a good practice to double-click and run it directly on the host PC to ensure it works as expected. With these simple setups, your remote gaming experience will be more complete and professional.
Related Contents
“Claude Code requires Git Bash” Error on Windows? Here's the Easy Fix
Duration: 00:00 | DP | 2025-11-14 22:39:00Recommended
PHP TypeError Deep Dive: How to Fix 'Argument must be of type ?array, string given'
00:00 | 7In modern PHP development, type hinting significan...
One-Command Website Stability Check: The Ultimate Curl Latency Test Script for Zsh
00:00 | 6Need a fast, reliable way to test the latency and ...
Dynamically Update Page Titles in Vue Router: From Basics to i18n and TypeScript
00:00 | 10Still manually updating page titles in your Vue ap...
Boost Your WebStorm Productivity: Mimic Sublime Text's Cmd+D Multi-Selection Shortcut
00:00 | 5Developers switching from Sublime Text to WebStorm...