Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know what should be the condition in my if loop if i want to shutdown my system if the condition is reached.
I mean if my if loop looks like this..
if(time>8pm || system shutdown)
then what should i write in place of system shutdown?
Posted

Hi,

System.Diagnostics.Process.Start("shutdown", "/s /t 0");
It may helps you.
Regards,
shefeek
 
Share this answer
 
v2
C#
System.Diagnostics.Process.Start("shutdown -s");
 
Share this answer
 
Use InteropServices namespace in your code as
using System.Runtime.InteropServices;

then declare
C#
[DllImport("user32.dll")]
        public static extern int ExitWindowsEx(int uFlags, int dwReason);


and then use ExitWindowEx with appropriate parameter as event where you want to shutdown your system
ExitWindowsEx(1, 0);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900