Page 1 of 1

Cannot get a simple script to work

Posted: 18 Dec 2009 10:11
by Minimax
Hi

I just wanted to run WinRAR from a User Button but I am getting script errors. They say the system cannot find the file. The program's exe is definitely in the folder shown in the screenshot. I am using Vista Premium x64.

I consulted the XYwiki and according to it the syntax is right.

http://88.191.26.34/XYwiki/index.php/Sc ... mmand:_run

Image

Thanks.

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 10:28
by ogroeger
I see you are in Switzerland, so i suspect you use a german localisation. Thus try

Code: Select all

run "C:\Programme\WinRAR\WinRar.exe"

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 10:34
by Stefan
I don't know nothing, but...

...if smtg doesn't work, just try customizing the quotes

E.g.
::run "c:\PROGRAM FILES\Siren\siren.exe";
doesn't works

but
::run """c:\PROGRAM FILES\Siren\siren.exe""";
does.

That's
::run " " " path\name.ext " " ";


If i find the explanation again i will post them too.

EDIT:
The Explanation, collected from this forum (i have an text file to store this for future investigation):
Using Quotes in Scripting

It's strongly recommended that you (double- or single-) quote your strings!
While the script engine is currently still permissive with unquoted strings (msg Hi! works)
this might not be so in the future, so you better do msg "Hi!" right away!

Here's the basic laws of quoting:

(1) Everything is either in double-quotes, or in single-quotes, or outside of any quotes.
(2) To have double-quotes inside double-quotes they must be doubled.
(3) To have single-quotes inside single-quotes they must be doubled.
(4) Variables are resolved in double-quotes and outside of any quotes, but not in single-quotes

That's also why in the examples of use below for selfilter, you have this:
http://88.191.26.34/XYwiki/index.php/Sc ... _selfilter
selfilter "readme"; //Selects all items whose name contains "readme" (eg: readme, readme.txt, !readme.now)
selfilter """readme"""; //Selects item named "readme" and only that one item
selfilter "foobar"; // pattern is foobar
selfilter '"foobar"'; // pattern is "foobar"

So here's my explanation:

1.) c:\PROGRAM FILES\Siren\siren.exe is an string with space and have to be quoted:
"c:\PROGRAM FILES\Siren\siren.exe"
DQStringDQ

2.) but the script engine removes the outer quotes, that's why double the double quotes:
""c:\PROGRAM FILES\Siren\siren.exe""
DQDQStringDQDQ

3.) since this would be interpreted now as "emptystring" + c:\PROGRAM FILES\Siren\siren.exe + "emptystring" , again double the outer quotes:
"""c:\PROGRAM FILES\Siren\siren.exe"""
DQDQDQStringDQDQDQ

Three "s means: give me one literal double quote, quasi an string of nothing but one double quote .


You can also make this whole quoting-thinggy short by
just protecting the inner double quotes with outer single quotes:
'"c:\PROGRAM FILES\Siren\siren.exe"'
SQDQStringDQSQ


Or use Quote() function:
Run quote("c:\PROGRAM FILES\Siren\siren.exe");


HTH? :lol:

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 10:44
by Minimax
ogroeger wrote:I see you are in Switzerland, so i suspect you use a german localisation. Thus try

Code: Select all

run "C:\Programme\WinRAR\WinRar.exe"
Tried it, didn't work. Thanks though.

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 10:49
by zer0
Minimax wrote:Tried it, didn't work. Thanks though.
Easy. Paths with spaces must be single quoted as well as double quoted. Try this

Code: Select all

run '"C:\Program Files\WinRAR\WinRar.exe"';

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 11:01
by Minimax
Thank you all.

I will try your suggestions as soon as time permits and give feedback.

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 11:21
by ogroeger
Minimax wrote:
ogroeger wrote:I see you are in Switzerland, so i suspect you use a german localisation. Thus try

Code: Select all

run "C:\Programme\WinRAR\WinRar.exe"
Tried it, didn't work. Thanks though.
Funny! :shock:
I have Win7 64bit german and this works (i use WinRAR, too). Are you sure you have the 64bit version of WinRar installed? The 32bit version resides in a different directory.

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 11:29
by Minimax
ogroeger wrote:
Minimax wrote:
ogroeger wrote:I see you are in Switzerland, so i suspect you use a german localisation. Thus try

Code: Select all

run "C:\Programme\WinRAR\WinRar.exe"
Tried it, didn't work. Thanks though.
Funny! :shock:
I have Win7 64bit german and this works (i use WinRAR, too). Are you sure you have the 64bit version of WinRar installed? The 32bit version resides in a different directory.
Yeah, "Funny" was my first thought as well. :roll: I forgot to tell that I am running Vista under LUA. Perhaps this is the reason.

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 11:32
by zer0
ogroeger wrote:Funny! :shock:
I have Win7 64bit german and this works (i use WinRAR, too). Are you sure you have the 64bit version of WinRar installed? The 32bit version resides in a different directory.
His script error window points to 'Program Files' and not 'Programme'. The error message states that it cannot find the file specified. 2 possible reasons for that: a) path wasn't single quoted (we know this for sure from the screenshot) or b) path points to an incorrect location (we don't know this for sure, but it's possible). The reason why it works on your system is because there is no space in your path, so one pair of double quotes is acceptable ;)

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 11:39
by Minimax
Another thing. The path must point to the correct exe because XY could extract WinRAR's Icon from exactly the same path having "Program Files" in its string. So case b) can be ruled out. The WinRAR icon is recognizable in the screenshot. I am using WinRAR x64 by the way.

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 13:43
by Stefan
Just an side-question btw:
Stefan wrote:E.g.
::run "c:\PROGRAM FILES\Siren\siren.exe";
doesn't works
But
::run "c:\PROGRAM FILES\Siren\siren.exe" "arg";
or even
::run "c:\PROGRAM FILES\Siren\siren.exe" "";
do work!

Is there an explanation? :roll:

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 14:08
by jacky
Stefan wrote:Just an side-question btw:
Stefan wrote:E.g.
::run "c:\PROGRAM FILES\Siren\siren.exe";
doesn't works
But
::run "c:\PROGRAM FILES\Siren\siren.exe" "arg";
or even
::run "c:\PROGRAM FILES\Siren\siren.exe" "";
do work!

Is there an explanation? :roll:
run is a special case, and there you need to quote the path if it contains blanks, as is the case here. Either put the whole thing in single-quotes, or triple your double quotes:

Code: Select all

::run '"c:\PROGRAM FILES\Siren\siren.exe"';
::run """c:\PROGRAM FILES\Siren\siren.exe""";
Both should work fine.

As for the reason it works if you add an extra param, even just an empty string, is - I suspect - that in such case XY "auto-adds" quotes over the whole thing, due to that parser of his that will accept this:

Code: Select all

msg hello there!;
(And also, that your siren.exe probably ignores any argument passed to it...)

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 14:55
by Minimax
It's in the wiki as well. I just didn't look thoroughly enough. :oops:

Image

Re: Cannot get a simple script to work

Posted: 18 Dec 2009 15:45
by Stefan
Thanks jacky.
jacky wrote: As for the reason it works if you add an extra param, even just an empty string,
is - I suspect - that in such case XY "auto-adds" quotes over the whole thing,
due to that parser of his that will accept this:

Code: Select all

msg hello there!;
> I suspect
Yes, could be. Maybe Don can bring in some light?
jacky wrote:(And also, that your siren.exe probably ignores any argument passed to it...)
No, it not ignoring args, it just handles them smart: IF the arg can be used for good THEN use it, ELSE drop them and suppress error messages.

Minimax wrote:It's in the wiki as well. I just didn't look thoroughly enough. :oops:
Don't be " :oops: ".
The wiki was edited after your issue.