When running the following statement below I get the following message:

Cannot use Parentheses when calling a Su

WshShell.Run ("C:\SageQuest\MSDETemp\setup.exe",,8

When I remove the parentheses as follows it runs fine

WshShell.Run "C:\SageQuest\MSDETemp\setup.exe",,

Why do I get this error when intellsense give me the argument template?

Thank

Louis

Re: Cannot Use Parentheses when calling a Sub by Nils

Nils
Fri Apr 30 16:13:40 CDT 2004

> Cannot use Parentheses when calling a Sub

correct. It is not too elegant, but this is what it works like: You must use
parentheses when calling a function. You must not when calling a sub. It
does not matter whether the function is declared as a function - it is the
syntax of the call that makes the difference.

> Why do I get this error when intellsense give me the argument
> template?

Seems that Intellisense is not intelligent enough here ...

Regards, Nils
--
Nils Kaczenski - MVP Windows Server



Re: Cannot Use Parentheses when calling a Sub by Torgeir

Torgeir
Fri Apr 30 16:26:35 CDT 2004

Louis wrote:

> When running the following statement below I get the following message:
>
> Cannot use Parentheses when calling a Sub
>
> WshShell.Run ("C:\SageQuest\MSDETemp\setup.exe",,8)
>
> When I remove the parentheses as follows it runs fine:
>
> WshShell.Run "C:\SageQuest\MSDETemp\setup.exe",,8
>
> Why do I get this error when intellsense give me the argument template?
Hi

First, I think you are using the parameters to the Run method
incorrectly, the third parameter (bWaitOnReturn ) is supposed
to be True or False only. The second parameter (the one you have
set to nothing) is the one you want to set to 8 I guess, something
like this:

WshShell.Run "C:\SageQuest\MSDETemp\setup.exe", 8, True


Back to your question:

Sometimes you need to use parentheses when calling the Run
method, and sometimes not, so the intellisense in an editor
just need to default to either use a parenthese in the
template or not (it cannot detect what is correct for your
exact situation there and then), and the author of your
editor has selected to default to using a parenthese in
the template.

An example where the Run method needs to use parentheses:

If you had wanted to pick up the return code from setup.exe,
this is the code you would have needed to use:

sRC = WshShell.Run ("C:\SageQuest\MSDETemp\setup.exe", 8, True)


If you had tried to remove the parentheses here, you would have gotten
this error message:

"Microsoft VBScript compilation error: Expected end of statement"


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx