How to logoff,reboot,shutdown machine using javascrpt code
Before implementing this code please read the note below the code carefully.
function Shutdown() {
var ws = new ActiveXObject("WScript.Shell");
ws.Exec("shutdown.exe -s -t 30 ");
}
just call this function whenever require.
-s: used for shut down
-t:time limit
In 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.
hi
this code error comes automation server canot create object