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
EDIT:
I think when you are after a file you will have to change ShortPath to ShortName, though I havent tested this.