function Shutdown()
{
var ws = new ActiveXObject("WScript.Shell");
ws.Exec("shutdown.exe -s -t 30 ");
}
just call above function whenever required.
-s: used for shut down
-t:time limitIn above code time limit is 30 second.It will show alert for 30 second that your machine is shutting down .use -l instead of -s for log off and use -r for reboot
Note :The Initialize and Script ActiveX controls not marked as safe option should be selected as Enable.Goto Tool Menu in browser ->Internet Option ->Security -> select Local intranet -> Click Custom Level ->go to "Initialize and Script ActiveX controls not marked as safe" and mark as enable. Do this otherwise it will show error automation server canot create object.
No comments:
Post a Comment