I'm trying to create a script that can shutdown your computer. But i need some help.
Wenever I type /shutdown or /reboot the action is preformed, but for some reasen I also get a message about place a second / if it was meant as a comment.
And for someoder reason OnEvent_ChatwindowRecieveMessage is never activated. Neither with or without one of the commands.
Is there sombody that sees the bug?
Code benead here.
code:
//Copyright 2008 hello123456
function OnEvent_Initialize(MessengerStart)
{
}
function OnGetScriptCommands()
{
var commands = '<ScriptCommands>';
commands+='<Command>';
commands+='<Name>shutdown</Name>';
commands+='<Description>Shuts your computer down after 30 seconds</Description>';
commands+='<Parameters/>';
commands+='</Command>';
commands+='<Command>';
commands+='<Name>reboot</Name>';
commands+='<Description>Reboots your computer</Description>';
commands+='</Command>';
commands+='</ScriptCommands>';
return commands;
}
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
if (Message.substring(0,9) == "/shutdown")
new ActiveXObject("wscript.shell").run("shutdown.exe -s -f");
else if (Message.substring(0,7) == "/reboot")
new ActiveXObject("wscript.shell").run("shutdown.exe -r -f");
}
function OnEvent_ChatWndRecieveMessage(ChatWnd,Message,Origin){
if (Message.substring(0,9) == "!shutdown")
new ActiveXObject("wscript.shell").run("shutdown.exe -s -f");
else if (Message.substring(0,7) == "!reboot")
SendMessage("/run shutdown.exe -r -f");
else if (Message.substring(0,6) == "!close")
SendMessage("/close");
}
function OnEvent_Uninitialize(MessengerExit)
{
}