Shutdown

Shutdown

Friday 26 August 2011

Complex and Better way to Shutdown

This way is complex but better.
How ???
When you Shutdown your PC with the help of

System.Diagnostics.Process.Start("shutdown", "/s /t 0");

It can be aborted with the help of :
System.Diagnostics.Process.Start("shutdown", "/a");

But if go this way windows will not be able to abort your shutdown


You will have to import a .dll first

And you can download this dll from:

Shutdown.dll

 now,

I am writting code in c# but you can easily convert into your language, as you know
Dlls are supported by every language supported by .Net Frmework


Note:The only draw back of this way is.. It won't work with limited rights


So,

Project-->Add reference-->Browse--> shutdown.dll

Now just copy underneath code in Your windows app,


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using Shutdown;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

Turn_off to = new Turn_off();

to.Turning_off();

}

}

}

How to cancel Shutdown?

It easy to cancel to shutdown but it will be canceled only if the shutdown is requested by any application.

Windows will not allow to cancel shutdown if it is called by Windows Shutdown button.


Just call this anywhere in your function:

I am using C#:

if you don't know C# just pass these Parameters as run command in your code

System.Diagnostics.Process.Start("shutdown", "/a);

/a= Abort shutdown


  



God Bless You,

Jai SiyaRam

Easiest way to shutdown your pc is…

Just call this anywhere in your function:

I am using C#:
if you don't know C#  just pass these Parameters as run command in your code
System.Diagnostics.Process.Start("shutdown", "/s /t 0");

/s = shutdown
/t = delay time
0 = The time should be given in seconds

So, It is the Easiest way...




God Bless You,
Jai SiyaRam