ShutDown C# Project -
i coding programme should shutdown/restart when button pressed , when press shutdown or restart button , operation done without waiting specified time in (datetimepicker).
here's code :
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace windowsformsapplication8 { public partial class form2 : form { private datetime tm; public form2() { initializecomponent(); } private void button1_click(object sender, eventargs e) { if (datetime.now.compareto(tm) > 0) { sti(); system.diagnostics.process.start("shutdown", "/s"); } else { messagebox.show("your computer shutdown shortly ...."); } } private void sti() { if (datetime.now.timeofday.compareto(tm.timeofday) > 0) { tm = new datetime(datetime.now.year, datetime.now.month, datetime.now.day + 1, tm.hour, tm.minute, tm.second); } else { tm = new datetime(datetime.now.year, datetime.now.month, datetime.now.day, tm.hour, tm.minute, tm.second); } } private void notifyicon1_mousedoubleclick(object sender, mouseeventargs e) { this.show(); } private void notifyicon1_mouseclick(object sender, mouseeventargs e) { } private void button2_click(object sender, eventargs e) { if (datetime.now.compareto(tm) >= 0) { sti(); system.diagnostics.process.start("shutdown", "/r"); } else { messagebox.show("your computer shutdown shortly ...."); } } } }
use -t
switch of shutdown
specify waiting period
shutdown {-r|-s} -t xxx
where xxx number of seconds wait.
c# project shutdown
No comments:
Post a Comment