Shoutbox

How wo Run a Program through Javascript - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: How wo Run a Program through Javascript (/showthread.php?tid=62637)

How wo Run a Program through Javascript by Joereynolds89 on 07-06-2006 at 12:18 AM

I need to run a program through javascript, mainly to answer someone elses thread but also to try to teach myself how to script

The person im trying to help while teaching myself
http://shoutbox.menthix.net/showthread.php?tid=62632

so far i have

quote:
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage)
{
  if (sMessage == "/WMP")
  {
(Whatever command needed to run the program here, default directory for application is C:\Program Files\Windows Media Player\wmplayer.exe as far as i know)
    return "";
  }
  else
  {
  MsgPlus.DisplayToast("WMP", "Loading WMP Failed");
  }
}


Any help will be greatly appreciated!

Regards, Joe
RE: How wo Run a Program through Javascript by ShawnZ on 07-06-2006 at 12:27 AM

http://shoutbox.menthix.net/showthread.php?pid=679035


RE: How wo Run a Program through Javascript by Joereynolds89 on 07-06-2006 at 12:36 AM

Ok Shawnz ive used what you stated in that forum but i dont understand how you have it working?? could you please assist or someone??

quote:
function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_ChatWndSendMessage(ChatWnd, sMessage)
{
  if (sMessage == "/WMP")
  {
    var WSS = new ActiveXObject("WScript.Shell");
    return WSS.Run("C:\Program Files\Windows Media Player\wmplayer.exe");
  }
  else
  {
  MsgPlus.DisplayToast("WMP", "Loading WMP Failed");
  }
}
function OnEvent_Uninitialize(MessengerExit)
{
}


RE: How wo Run a Program through Javascript by ShawnZ on 07-06-2006 at 12:38 AM

why is that else there..


RE: How wo Run a Program through Javascript by Joereynolds89 on 07-06-2006 at 12:40 AM

incase the function fails? it displays a toast notifying you?

EDIT: apart from it notifys you its failed everytime you write anything :S


RE: RE: How wo Run a Program through Javascript by alexp2_ad on 07-06-2006 at 12:43 AM

quote:
Originally posted by Joereynolds89
incase the function fails? it displays a toast notifying you?

Lol, that sends a toast for every message that isn't /WMP
RE: How wo Run a Program through Javascript by Joereynolds89 on 07-06-2006 at 12:44 AM

yer i just noticed that :( can you give me any help on the script itself then, it is my first try and i dont even no php or anything yet only liek basic html lmao :(


RE: How wo Run a Program through Javascript by Lou on 07-06-2006 at 12:53 AM

quote:
Originally posted by Joereynolds89
Javascript
It's not javascript. It's the similar language, Jscript.
quote:
Originally posted by Joereynolds89
php
quote:
Originally posted by Joereynolds89
html
Where do any of these come in?

I think you should read the scripting documentations if you have not already done so, to understand how scripts are written.
RE: How wo Run a Program through Javascript by Joereynolds89 on 07-06-2006 at 01:00 AM

With php and Html i was just saying i have no knowledge of scripting or programming anywhere, therefore its very hard, if a type of programming/scripting etc is already known its much easier to understand and catch onto new ones!

i have read the scripting documentations i just cant see anything telling me how to run an app through Jscript


RE: How wo Run a Program through Javascript by Keikonium on 07-06-2006 at 01:08 AM

code:
function fnShellExecuteJ()
{
var objShell = new ActiveXObject("Shell.Application");

objShell.ShellExecute("C:\Program Files\Windows Media Player\wmplayer.exe", "", "", "open", 1);
}

^^ Found that here but I don't know if its what you are looking for, or if it would even work lol. I don't have the first clue about coding unless its php or html (A) (which are useless here ;)).

Just trying to help out :). Good luck! (Y)
RE: How wo Run a Program through Javascript by Pai on 07-06-2006 at 02:01 AM

You need double-slashes, ie C:\\Pro...

use this:

code:
new ActiveXObject("wscript.shell").run('C:\\Program Files\\Windows Media Player\\wmplayer.exe');

RE: How wo Run a Program through Javascript by wlmcrap on 07-06-2006 at 09:48 PM

Heres another way:


function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message == "!wmp")
{
ChatWnd.SendMessage("/run C:\\Program Files\\Windows Media Player\\wmplayer.exe");
return "";
}
}


RE: How wo Run a Program through Javascript by Joereynolds89 on 07-06-2006 at 09:53 PM

yer i figured that out, sorry i havnt had time to get roudn to posting it for you wlmcrap but you foudn it yourself :P

EDIT:

Mine shows this though


[Code]function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message == "/WMP")
{
ChatWnd.SendMessage("/run C:\\Program Files\\Windows Media Player\\wmplayer.exe");
MsgPlus.DisplayToast("WMP", "WMP is Loading...", 'notify.mp3', "", "");
return "";
}
}
function OnEvent_Uninitialize(MessengerExit)
{
}[/code]

For notify to work it needs to be installed in the directory with the script just incase you didnt no :P



RE: How wo Run a Program through Javascript by foaly on 07-06-2006 at 10:31 PM

to display toast on error:

code:
function OnEvent_Initialize(MessengerStart)
{
}
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message == "/WMP")
{
try{
ChatWnd.SendMessage("/run C:\\Program Files\\Windows Media Player\\wmplayer.exe");
MsgPlus.DisplayToast("WMP", "WMP is Loading...", 'notify.mp3', "", "");
}catch(err){
MsgPlus.DisplayToast("WMP", "Loading WMP failed", 'notify.mp3', "", "");
}
return "";
}
}
function OnEvent_Uninitialize(MessengerExit)
{
}