system-shutdown

How to pause Windows shutdown

狂风中的少年 提交于 2019-12-01 20:11:03
I need to mute/un-mute the sound card at startup and shutdown. I have found some code to do the work, but often Windows slams through the shutdown and the sound never gets muted. Can someone please tell me how to pause the shutdown long enough for my app to mute the sound? I can use a simple TTimer to pause the app long enough for it to run the muting and then let Windows get on with shutting down. How do I tell Windows to wait though? I notice that if I leave Firefox running and try to shutdown, Windows stops with a message, "These programs are preventing windows closing..." and needs a click

Detecting a scheduled shutdown

喜欢而已 提交于 2019-12-01 03:50:34
I have a cmd script that will execute a set of patches, and it's designed to abort if a reboot is required to avoid patching issues. I'd also like to extend the script to abort if a reboot is scheduled (E.g. via the "shutdown" command) in order to avoid reboots mid patch if possible. Unfortunately I haven't managed to find a way to detect this apart from attempting to schedule another shutdown, which results in: A system shutdown has already been scheduled.(1190) While I could theoretically use this I don't think it would be good practice to scare logged in users every time I needed to check

shutting down computer (linux) using python

烈酒焚心 提交于 2019-11-29 12:23:05
问题 I am trying to write a script that will shut down the computer if a few requirements are filled with the command os.system("poweroff") also tried os.system("shutdown now -h") and a few others. but nothing happens when I run it, the computer goes through the code without crashing or producing any error messages and terminates the script normally, without shutting down the computer. How does one shutdown the computer in python? edit: Seems that the commands I have tried requires root access. Is

How to abort shutdown in Windows (XP|Vista) programatically?

折月煮酒 提交于 2019-11-27 22:25:18
I want to be able to 1. detect (and, if needed 2. abort) OS shutdown from my application, preferably by using the Windows API. I know that it is possible to abort shutdown manually using the command shutdown -a In the worst case, I could ShellExecute this, but I was wondering if there was a better way to prevent the shutdown programatically. Maybe it would be enough to be notified programatically that the OS is about to shut down - how to do this? Piskvor From MSDN : The WM_QUERYENDSESSION message is sent when the user chooses to end the session or when an application calls one of the system

How to detect pending system shutdown on Linux?

心不动则不痛 提交于 2019-11-27 21:15:48
I am working on an application where I need to detect a system shutdown. However, I have not found any reliable way get a notification on this event. I know that on shutdown, my app will receive a SIGTERM signal followed by a SIGKILL . I want to know if there is any way to query if a SIGTERM is part of a shutdown sequence ? Does any one know if there is a way to query that programmatically (C API)? As far as I know, the system does not provide any other method to query for an impending shutdown. If it does, that would solve my problem as well. I have been trying out runlevels as well, but

Detecting windows shutdown event

我怕爱的太早我们不能终老 提交于 2019-11-27 19:27:13
问题 I have a windows Service always running once PC started, how would i detect using .NET 3.5 or WMI, when the user or some other application/process has requested a shutdown or reboot in windows. I do not want to stop it, just log the time and who initiated the shutdown (user or process is fine, don't really need to know which process) Thank you 回答1: Use the Microsoft.Win32.SystemEvents.SessionEnding event. However, note that you are in a Windows Service, and this event won't fire for you

Run a script only at shutdown (not log off or restart) on Mac OS X

强颜欢笑 提交于 2019-11-27 14:26:11
Is there any way to run a script only at shutdown? I mean, only when the computer is really shutting down to off state. This script should not run when doing just a log off or restart. Few days ago I published on github a configuration/script able to be executed at boot/shutdown . Basically on Mac OS X you could/should use a System wide and per-user daemon/agent configuration file (plist) in conjunction with a bash script file. This is a sample of the plist file you could use: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs

How to power down the computer from a freestanding environment?

99封情书 提交于 2019-11-27 09:04:51
I'm making a protected-mode OS based on Intel's x86 architecture, and was looking for some information on how to power off the computer via assembly code, or something like that. Could you help me with this problem? from http://forum.osdev.org/viewtopic.php?t=16990 The ACPI shutdown is technically a really simple thing all that is needed is a outw(PM1a_CNT, SLP_TYPa | SLP_EN ); and the computer is powered off. The problem lies in the gathering of these values especially since the SLP_TYPa is in the _S5 object which is in the DSDT and therefore AML encoded. Below is a simple "map" of where to

How cancel shutdown from a windows service C#

半世苍凉 提交于 2019-11-27 07:24:34
问题 I have a windows service started (written in C# .net2.0). I want to detect when the computer shutdown/reboot and cancel it. After the cancel I want do some actions and restart windows. I have tried it, but it not working using Microsoft.Win32; partial class MyService: ServiceBase { protected override void OnStart(string[] args) { SystemEvents.SessionEnding += new SessionEndingEventHandler(OnSessionEnding); } private void OnSessionEnding(object sender, SessionEndingEventArgs e) { e.Cancel =

C# - How to detect a Windows shutdown/logoff and cancel that action (after asking the user)

烂漫一生 提交于 2019-11-27 02:01:21
Some explanation: for a project I'm working on I have to write a program that is running in the background, detects changes to files, and uploads the modified files to a web service to make it available to others. Quite simple synchronization if it were not for the case when a user modifies a big file and decides to shutdown its computer right after the edit. I could cancel the upload and wait for the next reboot to do the upload, but I can imagine the user downloading the file from the web to another computer the next morning and don't understanding why his changes from last night aren't