Click here to Skip to main content
15,891,204 members
Everything / Shutdown

Shutdown

shutdown

Great Reads

by Thomas Daniels
A tip about how to shut down, restart, log off, lock, hibernate or sleep your computer in C#.

Latest Articles

by Thomas Daniels
A tip about how to shut down, restart, log off, lock, hibernate or sleep your computer in C#.

All Articles

Sort by Score

Shutdown 

19 Jun 2013 by Zoltán Zörgő
It might not cover all possible situations, but it will cover your requirements: Make Your Application Shutdown Aware[^]
19 Jun 2013 by OriginalGriff
You can add a handler to the SystemEvents.SessionEnding[^] event, but you should just get an appliction exit command through the normal channels - you can just ask in that.
21 Oct 2013 by CPallini
Well, apparently is not working. You should properly check WINAPI function return values (possibly reading some documentation too) in order to discover why it is not working.
10 Jul 2014 by Sergey Alexandrovich Kryukov
You can respond to this or other system events using the class Microsoft.Win32.SystemEvents. Please see:http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents%28v=vs.110%29.aspx[^].For example, while handling the event SystemEvents.SessionEnding, you can check up the reason...
9 Feb 2018 by OriginalGriff
No. The Application.ApplicationExit Event only fires when the current application is exiting, not when a different application is closed. It is possible to detect when a different app closes, but as Richard has said what you are trying to do sounds like malware; it's difficult to think of a...
10 Dec 2018 by Richard MacCutchan
At a guess Windows is preparing to install a major update. Calling shutdown form inside an application is never a good idea.
2 Mar 2020 by Dave Kreskowiak
You're launching CMD, which if you open a CMD prompt and type "CMD /?", you'll see the the argument to launch a process is "/C" if the want the CMD window to close when the process it launched exits. But, you don't even need to launch CMD at...
18 Mar 2021 by Patrick Skelton
The solution turns out to be embarrassingly simple. There was no return statement after the call to Application.Current.Shutdown() so the remainder of the Application.OnStartup() method was executing normally. The details are here: Why does my...
19 Jun 2013 by Vaibhav_J_Jaiswal
Hello Friends,I am new in C#, so anyone tell me the following conditions:1)I developed an application which is currently running.2)Now I am going for shut down the system.3)In this condition application ask me "Do you want to close the application?"4)My requirement is if I am going...
2 Jul 2013 by AnkitGoel.com
Try this-i think, you forgot to add spaces-Dim cmd Dim obj cmd = ("shutdown -s -t " & val(textbox1.text) * 60 " -f") obj = CreateObject("WScript.Shell") obj.run(cmd)
21 Oct 2013 by hk.v
I am using ExitWindowsEX() function to shutdown system. Its working in windows 7 and XP. But when i am running in the same thing in windows8 its not shutting down. I tried like this.,HANDLE hToken; TOKEN_PRIVILEGES tkp; if (OpenProcessToken(GetCurrentProcess(),...
5 Feb 2014 by pantelisZO
Hello!I have a PC (Dell, Windows 7), which is part of a bigger machine (composed from different hardware elements) and it is located in the interior of this machine. The external machine is conencted to the power supply via a central switch button. Once the user turns on the central switch,...
5 Feb 2014 by OriginalGriff
If your PC does not have a BIOS option for wake on power on, then you are very, very limited in what you can do: but most do - it may be worth contacting the motherboard manufacturer and asking them.The other alternative is "Wake on LAN" - it just needs a wired network connection and some...
1 Jun 2014 by Sergey Alexandrovich Kryukov
Was that so difficult to perform some search and read some original MSDN documentation? Say, this way: http://bit.ly/1tzCqGp[^].In...
10 Jul 2014 by GeorgeGkas
Hello guys,I want to know the code that saves my txt file automatically when the user press the shut down button on his computer, with Vb.Net code....if there is a way.The reason why I put myself -and now you- to think such a code is because I programed a Notepad and I want to minimize...
22 Sep 2014 by Mahnoosh_M
hi I use psshutdown.exe to remote shutdown computers but for windows 2008 and windows 7, when I use psshutdown.exe, it has error "ACCESS is denied " I use administrator username and password how can I solve it ?
17 Jun 2015 by Instance1991
Similar:Windows Update After the update is complete Output: "Please do not power off or unplug your machine. Installing update 12 of 15 ..." This kind of technology will be uesd ?Or what kind of API?Use C++ Programming Implemented
9 Feb 2018 by Giiman95
I'm wondering if I can use Application::ApplicationExit Event to cause my computer to shutdown if someone exits out of an app like Sticky Notes. Is here someone who could maybe provide some sample code on how I could do this? Very basic knowledge of coding. Your help is appreciated. What I have...
16 Mar 2018 by RickZeeland
You can try this, create a shortcut with this command: shutdown /s /t 0
10 Dec 2018 by Member 14084420
Sup, I tried creating a small programm to test the shutdown command 30 mins ago. program code: import os os.system(´shutdown-s´) Now instead of shutting down, windwos started preparing(30 mins ago) Any ideas what could have gone wrong? Or what i should do now? What I have tried: I only...
10 Dec 2018 by CPallini
The correct syntax for Windows shutdown is 'shutdown /s'. In any case the script must be executed with administrator rights in order to actually shutdown the system.
2 Mar 2020 by MadMyche
You may want to read the documentation for the Shutdown command; 1. You may need to use the /f (force) parameter with the hidden window style 2. Your time delay is invalid, maximum delay is 600 seconds. Reference: Shutdown | Microsoft Docs[^]
18 Mar 2021 by Patrick Skelton
I have a WPF application that, when needed, starts a separate update application and then attempts to close itself down using Application.Current.Shutdown(). This used to work fine. Now it doesn't. I don't know when this problem started because...
26 Jul 2021 by OriginalGriff
Do you have any idea how much work explaining code line by line is? Every single line needs a paragraph of explanation! For example: int next = r.Next(); Create a new variable called "next" which can hold a integer value. From...
26 Jul 2021 by Richard MacCutchan
Quote: This is code is not descriptive enough for beginners like me And that is a very good reason why you should keep away from it. If you want to learn Python then go to The Python Tutorial — Python 3.9.6 documentation[^].
24 Jun 2023 by Littery
I'm running Ubuntu 22.04.2 LTS and have dual boot windows 11. I'm trying to hide grub menu while booting and automatically boot ubuntu as I have seen that can be done with changing GRUB_TIMEOUT to 0 in /etc/default/grub and run sudo update-grub...
1 Dec 2014 by Thomas Daniels
A tip about how to shut down, restart, log off, lock, hibernate or sleep your computer in C#.
17 Mar 2021 by Richard Deeming
Are you trying to call the method from a background thread? Application.Shutdown Method (System.Windows) | Microsoft Docs[^]: This method can be called only from the thread that created the Application object.
4 Mar 2020 by Member 14761028
Hello, like the title say, I want to execute CMD command by pressing buttons in a Windows Form application. I want to create an application which shutdown my computer after a specific time. I´m new at Visual Studio and we only practiced a few...
12 Jul 2014 by GeorgeGkas
Ok I find it.You just use the FormClosing event!
2 Jul 2013 by zubair30
Sir,When I used following code in my vb.net project then it worked and shuted-down computer after 60 sec. Dim cmd Dim obj cmd = ("shutdown -s -t 60 -f") obj = CreateObject("WScript.Shell") obj.run(cmd)But I want to use a textbox in which...
1 Jun 2014 by talora
DearI would like to Shutdown or Restart or Logoff network PCs from my PC. Would you please let me know what would be the VB6 code? I also want to send message to the network PCs with the help of VB6 code.To shutdown remote PC, I’ve used below code but it doesn’t work. Please...
10 Jul 2014 by Hermann Jung
You are using winforms? Handle the FormClosing event. The EventArgs contains the CloseReason.
19 Sep 2014 by Garth J Lancaster
What credentials are you using on the Windows 7 system - my guess is you'd have to run the process 'elevated' / 'As Administrator' 'g'
16 Mar 2018 by Babiiii
Goodevening, I was trying to do a remote shutdown through lan on my other pc. I tried the shutdown -i command in the cmd and put the IP address of my other pc. Cmd outputs Access is denied (5). What I have tried: I tried to disable firewall. I also configured the secpol.msc and add Everyone in...
26 Jul 2021 by Member 14925860
This is code is not descriptive enough for beginners like me please help. What I have tried: import win32con import win32api import win32gui import sys import time def log_info(msg): """ Prints """ print msg f =...