Restart windows with godot game

Godot Version

4.1

Question

Would it be possible to make a godot game, that can make your pc restart at some points?
For example, dying in game would make your pc reset?

I wouldn’t think so. It’s not something I or probably many people, have thought of (Using GDSCript).

Also, if you find a way, don’t expect to make friends with that feature. Just saying.

3 Likes

I would very highly discourage even TRYING to implement a feature like that. Shutting off someone’s PC can lead to massive data loss, sometimes to catastrophic degree.
You can do some serious damage with an unexpected restart of someone’s PC.

Please don’t.

3 Likes

With a GDExtension you can make use of system libraries to reboot. You will likely need administrator permissions to call these functions which is unlikely for a game to be permitted.

Windows uses <windows.h> to initiate a restart on a windows PC

Linux may be more complicated with different init systems, but it seems <linux/reboot.h> contains a function to signal a reboot.

1 Like

Yes, it is possible.

Keep in mind that doing so will likely pop up an “Are you sure?” dialog from the OS.

Also keep in mind that doing so without asking the user’s permission would be considered malicious, and you could possibly get banned from itch, Steam, or anywhere else that you might put your game up.

You could also be identified as malware by virus scanning companies.

You could end up in legal trouble (i.e. getting sued).

4 Likes

I’m not sure if this would help.

This is the last event that I know of; before I come into my office and find that the PC fan is in fact spinning, but the pc is infact asleep/ or not. Everything else except shrinkwrapping my PC is obsolete

- System 

  - Provider 

   [ Name]  DSAService 
 
  - EventID 2003 

   [ Qualifiers]  0 
 
   Version 0 
 
   Level 4 
 
   Task 0 
 
   Opcode 0 
 
   Keywords 0x80000000000000 
 
  - TimeCreated 

   [ SystemTime]  2025-04-26T05:03:04.6495835Z 
 
   EventRecordID 53289 
 
   Correlation 
 
  - Execution 

   [ ProcessID]  0 
   [ ThreadID]  0 
 
   Channel Application 
 
   Computer Scarlett 
 
   Security 
 

- EventData 

   <DSAExceptionEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="https://www.intel.com"><OS><Description>Windows 10 Education</Description><Version>6.3</Version><Build>19045</Build><Release>2009</Release><EpmId>windows-10-22h2-64</EpmId></OS><DSAVersion>25.2.15.9</DSAVersion><Module>DSAExternalService.dll</Module><ClassName>DSAExternalService.External</ClassName><MethodName>GetProductsAndDownloads</MethodName><ExceptionType>NullReferenceException</ExceptionType><Message>Object reference not set to an instance of an object.</Message></DSAExceptionEvent>

@gionggone I honestly can’t tell if you have a very odd sense of humor or if you are a poetry AI.

I’m not sure if this question has already been answered but Godot 4.4.1 (and previous versions) allow you to access and run executables via code.

OS.execute("C:/Users/ASUS/AppData/Roaming/Spotify/Spotify.exe", []) # Path to your .exe

You can create an external program that restarts the user’s computer and run it via code.