system-shutdown

Run process during windows shutdown

点点圈 提交于 2020-01-07 01:30:53
问题 I have a Win32 service, that needs to run a .NET executable on service stop (for cleanup reasons). I recently discovered that the cleanup never happens on shutdown, because the process creation gets blocked by OS. Does anyone know a way to override this? Process, I am spawning is not invasive and should only run a fraction of a second. 回答1: The only way I could find to do it was: pre-create a child process suspended, and them un-suspend it on shutdown. 来源: https://stackoverflow.com/questions

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

≯℡__Kan透↙ 提交于 2019-12-28 04:08:09
问题 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. 回答1: 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

Computer Shut Off Python 3.4

*爱你&永不变心* 提交于 2019-12-25 04:07:44
问题 A friend of mine wants to automatically shut off his computer using Python 3.4 (to put in a program). Does anyone know a basic as-small-as-possible way to do this? OS: Mac OSX Yosemite Thanks 回答1: OS X is a Unix at its base, so you can use Unix commands. you can use either: #!/usr/bin/python import os os.system("shutdown -h now") Must be run as root, won't work otherwise. You can however add to sudoers ( man visudo ) shutdown as NOPASSWD program for the users that want to execute the script

Does android mobile has any error log file to debug cause for auto switch off?

旧巷老猫 提交于 2019-12-22 13:50:08
问题 Sometimes we see the device restarts automatically, while few other times I had found it switching off after long time, even battery was not low. So if we want to trace back of what actually has caused this, does we have any log file in device memory which has the cause of shutdown or restart ? Like we get the dump for the other O.S. for any errors occured causing it to restart/shutdown in specific error log file. Similarly does android has such ? It may be anywhere , even in internal memory,

Detecting a scheduled shutdown

核能气质少年 提交于 2019-12-19 05:45:30
问题 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

How to shutdown my system via a php site using LAMP server?

偶尔善良 提交于 2019-12-12 02:33:19
问题 This is the code i have so far site: <?php if ($_POST['action']=="Shutdown") { $test=shell_exec("touch /scripts/shutdown.sh"); } ?> shutdown.sh: #!/bin/sh if [ -f "/tmp/shutdown" ] then rm -f /tmp/shutdown /sbin/shutdown now fi I roughly got the idea from http://ubuntuforums.org/ But, when i run the php script on my local-host, it doesn't show up? Question : How to shutdown my system via a php site using LAMP server? Thanks in advance! 回答1: No need to create a script for it, you can just do:

Is there any API function for shutting down Windows while installing any pending updates?

↘锁芯ラ 提交于 2019-12-05 16:21:56
问题 I know the ExitWindowsEx() API function which simply shuts down Windows. But as far as I know, you cannot make Windows install any pending updates with it. Is there any API support for installing any pending updates (in that standard blue screen which says " n of m updates have installed - Please don't turn off or unplug your PC, Windows will shut down itself ") then shutting down Windows (equivalent to clicking the "Install updates and shutdown" menu option of the Windows user interface)?

Is there any API function for shutting down Windows while installing any pending updates?

烂漫一生 提交于 2019-12-04 02:47:20
I know the ExitWindowsEx() API function which simply shuts down Windows. But as far as I know, you cannot make Windows install any pending updates with it. Is there any API support for installing any pending updates (in that standard blue screen which says " n of m updates have installed - Please don't turn off or unplug your PC, Windows will shut down itself ") then shutting down Windows (equivalent to clicking the "Install updates and shutdown" menu option of the Windows user interface)? (OS Version: Windows XP and higher.) The best you can do is call InitiateShutdown and include the

shutting down computer (linux) using python

感情迁移 提交于 2019-12-03 05:18:12
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 there any way to shut down the machine from the script without elevated privileges? Many of the linux

How to pause Windows shutdown

喜你入骨 提交于 2019-12-01 21:25:15
问题 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