Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VBScripting Error

Posted on 2008-11-02
4
1,566 Views
Last Modified: 2012-05-05
I know basically nothing about vbscripting (just learning now), but was a programmer in a former life. I found some vbscripting code with a google search and want to automate the installation of a software update on numerous computers.  I receive "Cannot use parentheses when calling a Sub" but in my simple brain this is an "If" statement, not a "Call" to a sub.  I havent had any luck trying to figure out how to debug the code either.

Can anyone point out the error in this coding or why it appears to be a Sub routine.  How can I change it to a Call? I'll take all the helpful hints and recommendations your will provide.

Thanks
object.Run(strCommand, [intWindowStyle],[bWaitOnReturn])  
 
'INSTALL CLIENTBASE PLUS Ver 3.04.03 USING VBScript    
Set objShell = WScript.CreateObject("WScript.Shell")
spath = objShell.CurrentDirectory
 
If fso.FileExists(spath & "\cbpupdate30403003.EXE") Then
	path = """" & spath & "\cbpupdate30403003.EXE" & """ /s"
	objShell.Run(path, 1 ,True)
	i = 0
	'INSTALL CLIENTBASE PLUS Ver 3.04.03 Build 03    
	i = objShell.Run(path, 1 ,True)
	If (i = 0) Or (i = 3010) Then 
		'WRITE EXIT CODE [0-success/3010-success&requires reboot] TO EVENTLOG
		objShell.LogEvent vbLogSuccess, sLogHeader & "CLIENTBASE PLUS Ver 3.04.03 installation completed successfully." & 
 
VbCrLf & "Exit code: " & i
	Else
		MsgBox "The installation of CLIENTBASE PLUS returned an error: " & i & VbCrLf & _
		"Please contact IT Support to report this error.", vbOKOnly
		objShell.LogEvent vbLogError, sLogHeader & "Installation returned failure code: " & VbCrLf & "Exit code: " & i
	End If
	
Else
	WScript.Quit (1)
End If
 
set fso = Nothing
set WSHShell = Nothing
Wscript.Quit

Open in new window

0
Comment
Question by:conlin
  • 2
4 Comments
 
LVL 58

Expert Comment

by:tigermatt
ID: 22863504

In VBScript there is a Function declaration, and then a Sub declaration. Essentially you use a Function when it should accept parameters and return a value (the value is returned within the function by setting a variable the same name as the function to the appropriate value to be returned). A Sub is used when parameters may / may not need to be accepted, but there should be nothing returned.

Which line does the parser say the Paranthesis error is on?

-tigermatt
0
 

Author Comment

by:conlin
ID: 22863529
It doen't tell me anything. It fails with...
VBScript compilation error: Cannot use parentheses when calling a Sub.

Thanks where I'm stuck in the mud.
0
 

Author Comment

by:conlin
ID: 22863961
Never mind.  I figured out a much better way to accomplish what I wanted to do.

Thanks anyway.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 125 total points
ID: 22864574
Hi, the error you were getting most likely refers to lines like this:
objShell.Run(path, 1 ,True)

When you run a method in that fashion, with the parenthesis, you're expecting a return code, in which case you should use
boolReturn = objShell.Run(path, 1 ,True)

There are special cases where there's a slight exception to that rule, but I can't remember the reference right now.

Anyway, instead, if you don't require a return code, you can just use the same line without parenthesis, like this:
objShell.Run path, 1 ,True

and you won't get any errors.

Regards,

Rob.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check folder every for files and print them 5 39
Excel 2016 loop through 6 43
How to make shortcut to ftp site open in windows explorer not IE 3 35
Logon script fails 23 45
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question