What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Starting an application

Pages: (2): « First [ 1 ] 2 » Last »
Starting an application
Author: Message:
tobias
New Member
*


Posts: 5
Joined: Jan 2007
O.P. Starting an application
quote:
Originally posted by Chris Boulton
Starting a program:
var shell = new ActiveXObject("wscript.shell");
shell.Run("notepad.exe");

(Will start notepad.exe)


How would you start an application not in the default windows directory, like iTunes, XFire, FireFox, etc.?
01-07-2007 05:21 AM
Profile E-Mail PM Find Quote Report
Ash_
Senior Member
****

Avatar

Posts: 638
Reputation: 31
35 / Male / –
Joined: Aug 2004
RE: Starting an application
i'm not completely sure because i usually use CreateProcess but what happens if you go like.
code:

var shell = new ActiveXObject("wscript.shell");
shell.Run("../aa.exe");


would aa.exe run (place it in the directory above the default one, usually just C:/)

This post was edited on 01-07-2007 at 07:15 AM by Ash_.
[Image: jeansiger5.jpg]
01-07-2007 07:14 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Starting an application
quote:
Originally posted by tobias
How would you start an application not in the default windows directory, like iTunes, XFire, FireFox, etc.?
code:
function _start_app(_path){
    new ActiveXObject('WScript.Shell').run(_path);
}

Usage:
code:
_start_app('C:\\Program Files\\iTunes\\iTunes.exe');
01-07-2007 07:15 AM
Profile E-Mail PM Find Quote Report
tobias
New Member
*


Posts: 5
Joined: Jan 2007
O.P. RE: Starting an application
Thank you. Now to get to work! ;)

EDIT: Not working, from what I can see.


function _start_app(_path){
    new ActiveXObject('WScript.Shell').run(_path);
}
function OnEvent_ChatWndSendMessage(ChatWind,Message)
{

(There are some if statements and things here)

            if(Message=="!photoshop"){
                MsgPlus.DisplayToast("Photoshop", aMessage);
                _start_app("c:\\Program Files\\Adobe\\Photoshop CS\\Photoshop.exe");
            }
}

And it shows the taost, but doesn't launch the program, and most of the time it doesn't show up in the chat window if it starts with !, but this time it does.

P.S. I know you don't like people using ! commands, but I can't figure out how to get my commands on the / list.

This post was edited on 01-07-2007 at 02:10 PM by tobias.
01-07-2007 01:52 PM
Profile E-Mail PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: Starting an application
quote:
Originally posted by tobias
P.S. I know you don't like people using ! commands, but I can't figure out how to get my commands on the / list.

code:
function OnGetScriptCommands(){

    var ScriptCommands = '<ScriptCommands>';

         ScriptCommands += '<Command>';
         ScriptCommands += '<Name>purple</Name>';
         ScriptCommands += '<Description>Makes the window purple</Description>';
         ScriptCommands += '</Command>';

         ScriptCommands += '<Command>';
         ScriptCommands += '<Name>green</Name>';
         ScriptCommands += '<Description>Makes the window green</Description>';
         ScriptCommands += '</Command>';

    ScriptCommands  += '</ScriptCommands>';

              return ScriptCommands;
}

This post was edited on 01-07-2007 at 02:42 PM by hmaster.
[Image: sig.png]
01-07-2007 02:38 PM
Profile PM Web Find Quote Report
tobias
New Member
*


Posts: 5
Joined: Jan 2007
O.P. RE: Starting an application
Thanks, I'll add that now. :)
Now does anyone have any ideas as to my first problem?
01-07-2007 03:32 PM
Profile E-Mail PM Find Quote Report
foaly
Senior Member
****

Avatar

Posts: 718
Reputation: 20
38 / Male / Flag
Joined: Jul 2006
RE: Starting an application
does the debugger give an error?
01-07-2007 03:34 PM
Profile E-Mail PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: Starting an application
quote:
Originally posted by tobias

Now does anyone have any ideas as to my first problem?

The problem is the spaces in the path. I don't know what to replace it with though. I've tried %20 but that didn't work.

This post was edited on 01-07-2007 at 03:42 PM by hmaster.
[Image: sig.png]
01-07-2007 03:41 PM
Profile PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: Starting an application
quote:
Originally posted by hmaster
quote:
Originally posted by tobias

Now does anyone have any ideas as to my first problem?

The problem is the spaces in the path. I don't know what to replace it with though. I've tried %20 but that didn't work.

you do what you normally would with a path containing spaces, put quotes around it. Which means you can either do this:
code:
new ActiveXObject("WScript.Shell").Run("\"C:\\Path Containing Spaces\"");
or to simplify things, use single quotes instead of double quotes for the string:
code:
new ActiveXObject("WScript.Shell").Run('"C:\\Path Containing Spaces"');

edit: added red highlighting to show double quotes on second example.
edit 2: updated matty's function to support paths containing spaces:
code:
function _start_app(_path){
    new ActiveXObject('WScript.Shell').run('"' + _path + '"');
}

This post was edited on 01-07-2007 at 03:54 PM by Eljay.
01-07-2007 03:52 PM
Profile PM Find Quote Report
hmaster
Senior Member
****

Avatar

Posts: 716
Reputation: 24
33 / Male / Flag
Joined: Nov 2004
RE: Starting an application
Thanks for that (Y).
[Image: sig.png]
01-07-2007 03:55 PM
Profile PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On