What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [question] Run commands from script

[question] Run commands from script
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: [question] Run commands from script
quote:
Originally posted by Eljay
quote:
Originally posted by markee
I think it returns the error because it doesn't like spaces.  I tried a few different things and the only way I got the run command to work was when there was no spaces in th files path (in a file or a folder).  The only way I could imagine getting past this is by using the likes of a *.bat file but I'm sure somone else will divise a better method.

indeed, it definitely doesnt seem to like spaces.
one way around this is to use the short version of the path which can be retrieved by calling Windows API function GetShortPathName.
Example:
code:
var ShortPath = Interop.Allocate((255+1)*2);
Interop.Call('kernel32', 'GetShortPathNameW', Messenger.ReceiveFileDir, ShortPath, 255);
new ActiveXObject('WScript.Shell').Run(ShortPath.ReadString(0));

Or you could just use ShellExecute, which does accept full paths:
code:
Interop.Call('shell32', 'ShellExecuteW', 0, 'open', Messenger.ReceiveFileDir, 0, 0, 1);

EDIT: zomg 2300 posts!

That works well but you could use this instead if you would prefer to just use ActiveXObjects rather than interop
code:
new ActiveXObject('WScript.Shell').Run(new ActiveXObject("Scripting.FileSystemObject").GetFolder(Messenger.ReceiveFileDir).ShortPath)
Btw, it is only one line long as well which looks nicer :P

EDIT:
I think when you are after a file you will have to change ShortPath to ShortName, though I havent tested this.

This post was edited on 09-11-2006 at 02:16 PM by markee.
[Image: markee.png]
09-11-2006 12:58 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[question] Run commands from script - by skorpan on 09-11-2006 at 10:58 AM
RE: Run commands from script - by Felu on 09-11-2006 at 11:00 AM
RE: RE: Run commands from script - by skorpan on 09-11-2006 at 11:12 AM
RE: [question] Run commands from script - by Felu on 09-11-2006 at 11:16 AM
RE: RE: [question] Run commands from script - by skorpan on 09-11-2006 at 11:17 AM
RE: [question] Run commands from script - by Felu on 09-11-2006 at 11:22 AM
RE: RE: [question] Run commands from script - by skorpan on 09-11-2006 at 11:26 AM
RE: RE: [question] Run commands from script - by alexp2_ad on 09-11-2006 at 11:26 AM
RE: RE: RE: [question] Run commands from script - by skorpan on 09-11-2006 at 11:34 AM
RE: [question] Run commands from script - by alexp2_ad on 09-11-2006 at 11:36 AM
RE: [question] Run commands from script - by Spunky on 09-11-2006 at 11:39 AM
RE: RE: [question] Run commands from script - by skorpan on 09-11-2006 at 11:42 AM
RE: RE: RE: [question] Run commands from script - by CookieRevised on 09-11-2006 at 04:15 PM
RE: [question] Run commands from script - by Spunky on 09-11-2006 at 11:44 AM
RE: RE: [question] Run commands from script - by skorpan on 09-11-2006 at 11:48 AM
RE: [question] Run commands from script - by Spunky on 09-11-2006 at 11:49 AM
RE: RE: [question] Run commands from script - by alexp2_ad on 09-11-2006 at 11:51 AM
RE: [question] Run commands from script - by Felu on 09-11-2006 at 12:18 PM
RE: RE: [question] Run commands from script - by alexp2_ad on 09-11-2006 at 12:20 PM
RE: [question] Run commands from script - by markee on 09-11-2006 at 12:19 PM
RE: [question] Run commands from script - by Spunky on 09-11-2006 at 12:31 PM
RE: [question] Run commands from script - by Eljay on 09-11-2006 at 12:48 PM
RE: [question] Run commands from script - by markee on 09-11-2006 at 12:58 PM
RE: [question] Run commands from script - by Shondoit on 09-11-2006 at 06:06 PM
RE: [question] Run commands from script - by CookieRevised on 09-12-2006 at 07:46 AM


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