[question] Run commands from script - 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: [question] Run commands from script (/showthread.php?tid=66092) [question] Run commands from script by skorpan on 09-11-2006 at 10:58 AM
Hi! RE: Run commands from script by Felu on 09-11-2006 at 11:00 AM
code: RE: RE: Run commands from script by skorpan on 09-11-2006 at 11:12 AM
quote:Thanks alot! Now I only need to know how I replace single "\" with "\\" in strings.. RE: [question] Run commands from script by Felu on 09-11-2006 at 11:16 AM
quote:I meant in scripting you'll need to use double slash(\\) instead of a single slash(\) in any path you specify. RE: RE: [question] Run commands from script by skorpan on 09-11-2006 at 11:17 AM
quote:I got that =) But the functions in Messenger Plus scripting enviroment returns path in the style of "c:\my dp folder\", so I need to change it to "c:\\my dp folder\\". That is my new problem RE: [question] Run commands from script by Felu on 09-11-2006 at 11:22 AM
quote:No, it returns the correct way... If it returns "c:\\my dp folder\\" the folder won't open but if it returns "c:\my dp folder\" the folder would open. I don't know the reason behind this, but i think you get what i mean. If someone can explain why then please do . RE: RE: [question] Run commands from script by skorpan on 09-11-2006 at 11:26 AM
quote:Wrong. The function in Messenger Plus I use returns a value in style of "c:\my folder\sub folder" (I add a "\" on the end manually). If I take this string and pass it on to Shell.Run(string); (where string is the returned path from above) it dies not open anytning. I just get a error message. RE: RE: [question] Run commands from script by alexp2_ad on 09-11-2006 at 11:26 AM
EDIT: What's the error you get, and what's the exact code you're using? quote:The reason is that in strings, the backslash \ is used as an "escape character", meaning it's used to show that the next character signifies something other than it's literal character. For example: \n = new line \" = inside a string this is used to show a quote, rather than actually showing the ending of the string So to get an actual \ into a string, you double it up to \\ and it gets changed into a \ when the string is passed / used etc. RE: RE: RE: [question] Run commands from script by skorpan on 09-11-2006 at 11:34 AM
quote:I wrote this above... quote: I ask again: How do I double it up in a string? RE: [question] Run commands from script by alexp2_ad on 09-11-2006 at 11:36 AM
You actually WANT a double \\ for some reason? RE: [question] Run commands from script by Spunky on 09-11-2006 at 11:39 AM
Can you not just use code: where strPath is the variable containing the path? EDIT: Damn, beaten to it again RE: RE: [question] Run commands from script by skorpan on 09-11-2006 at 11:42 AM
quote:... code:Returns something like: c:\my documents\my recieved files, right? This is stored in a string. Before I can use it with code:I need to change it into: c:\\my documents\\my recieved files. How do I do that? RE: [question] Run commands from script by Spunky on 09-11-2006 at 11:44 AM
code: That should do it. RE: RE: [question] Run commands from script by skorpan on 09-11-2006 at 11:48 AM
quote:Thanks alot! =) I solved it myself just before i read this But you actually did come with help that was useful =) RE: [question] Run commands from script by Spunky on 09-11-2006 at 11:49 AM
Hey no problem, although credit should probably goto Alexp2_ad as he got there faster than me RE: RE: [question] Run commands from script by alexp2_ad on 09-11-2006 at 11:51 AM
quote:And because you posted a triple backslash first didn't you? BTW, can anyone get this to work, I tried: new ActiveXObject('WScript.Shell').run(Messenger.ReceiveFileDir); But it returns an unknown error, it should work as is, but it doesn't, tried replacing \ or whatever, but it didn't help. RE: [question] Run commands from script by Felu on 09-11-2006 at 12:18 PM
quote: code:Should Work RE: [question] Run commands from script by markee on 09-11-2006 at 12:19 PM
quote: 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. EDIT: quote: alexp2_ad had the correct property, it does not have the extra 'd' RE: RE: [question] Run commands from script by alexp2_ad on 09-11-2006 at 12:20 PM
quote:Nooooooo, I don't like it when people post without checking the scripting docs trying to be a smart arse! quote: RE: [question] Run commands from script by Spunky on 09-11-2006 at 12:31 PM
quote: Spelling mistake... I knew what I meant to put RE: [question] Run commands from script by Eljay on 09-11-2006 at 12:48 PM
quote: 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: Or you could just use ShellExecute, which does accept full paths: code: EDIT: zomg 2300 posts! RE: [question] Run commands from script by markee on 09-11-2006 at 12:58 PM
quote: That works well but you could use this instead if you would prefer to just use ActiveXObjects rather than interop code:Btw, it is only one line long as well which looks nicer EDIT: I think when you are after a file you will have to change ShortPath to ShortName, though I havent tested this. RE: RE: RE: [question] Run commands from script by CookieRevised on 09-11-2006 at 04:15 PM
quote:You don't!! The Messenger.ReceiveFileDir (just as other similar functions) returns a proper string already. Do NOT change the slashes to double slashes! This will result in unwanting effects and possible errors. You need specifiy a double slash ONLY when you type the variable yourself like: MyString = "here I manually enter some text with some \\ slashes in \\ it and some new lines: \n\n\n hello" If you print out that variable you'll see: "here I manually enter some text with some \ slashes in \ it and ...." As explained before the slash is a special character and means "take the next character literally" (if the next character isn't a control character). So if you enter a string value manually you need to specify a double slash so the programming language knows it must take the second slash literally. However, when functions return variables, all the charaters inside the variable are already correct; the programming language has already taken the slashes literally: MyString = Messenger.ReceiveFileDir If you print out that string you will see again only single slashes as it should be and just the same as with the output of our previous string. If the returned string wasn't proper formatted you would not see something like "C:\Hello", but you would see "C:Hello". so... DO NOT CHANGE SLASHES TO DOUBLE SLASHES in strings returned by functions. RE: [question] Run commands from script by Shondoit on 09-11-2006 at 06:06 PM
It can work with a very simple solution... code:Just use quotes RE: [question] Run commands from script by CookieRevised on 09-12-2006 at 07:46 AM
quote:Which is actually no trick or something, but a basic standard logical thing. Thruout Windows you always must enclose your path in quotes if it contains spaces. |