VB Script error 800a03ee

New to VB .... Thanks for any help

In the attached file I'm getting an error in

line: 22
char: 4
error: expected')'
code: 800a03ee
fish_itAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
What file ?
0
fish_itAuthor Commented:
Sorry about that....
Copy-of-UPDATEWORDVBS.txt
0
toddbehnkeCommented:
objShell.run ("%comspec% /K cOPYING MSWORD MACROS... |" _
should  be
objShell.run ("%comspec% /K cOPYING MSWORD MACROS... |"  & _
notice the & _ at the end of the line, if that is the error,atleast I think it is, it is repeated on the other three objShell.run calls
0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

fish_itAuthor Commented:
I tried this and received an error...

lIne 24
char 32
error cannot use parentheses when calling  SUB...

I guess I need a class! I'm new to VS...
0
toddbehnkeCommented:
That is a different error all together. I am not too familiar with the shell scripting, but I would imagine that there is a syntax error in that objShell.run onces everything gets evaluated and concatenated together. Just a guess/hunch.
0
RobSampsonCommented:
Hi, your code should be like the below.  With VBS, if you are not actually catching the return value of a a function (objShell.Run returns an integer value if you want it), you cannot use the brackets.  For example, this is not valid
objShell.Run("cmd /k echo hello")

but these are
objShell.Run "cmd /k echo hello"
intReturn = objShell.Run("cmd /k echo hello")

Also, you were missing the second parameter at the end of the Run command, before True, where you specify the window type, which for a normal window, is 1.

Regards,

Rob.
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
strUserName = objShell.ExpandEnvironmentStrings("%USERNAME%")
 
strDriveLetter2 = "x:"
strRemotePath2 = "\\server\xxxxx\"
 
CheckDrive = objNetwork.EnumNetworkDrives
AlreadyConnected = False
For intDrive = LBound(CheckDrive) To UBound(CheckDrive) - 1 Step 2
      If UCase(CheckDrive(intDrive)) = "x:" Then AlreadyConnected = True
Next
 
If AlreadyConnected = True Then
      objNetwork.RemoveNetworkDrive strDriveLetter2
      objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
Else
      objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
End If
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... |" _
			"xcopy x:\localFolders " & chr34 & _ 
                        "C:\msword\localFolders\*.*" & _
			chr34 & " /E/D/I/R/Y", 1, true
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... |" _
			"xcopy x:\localFolders\wordmacros " & chr34 & _
			"c:\msword\wordmacros\*.*" & _
			chr34 & " /E/D/I/R/Y", 1, true
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... |" _
			"xcopy x:\localFolders\wordmacros " & chr34 & _
			"c:\Program files\Microsoft Office\Templates\VSC Forms\*.*" & chr34 & _
			" /E/D/I/R/Y", 1, true
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... |" _
			"xcopy x:\localFolders\wordmacros\normal.dot " & chr34 & _
			"c:\Program files\Microsoft Office\Templates\" & chr34 & _
			" /y", 1, true

Open in new window

0
fish_itAuthor Commented:
Thanks Rob...

I received an error
line 22
char 4
expected end of statement
code 800a0401
0
RobSampsonCommented:
Oh whoops, I've noticed a couple more small errors.....there was an ampersand missing from the end of each objShell.run line, and I also think your pipes ( | ) should be ampersands instead, to execute more that one statement ( && ):

Regards,

Rob.
Set objNetwork = CreateObject("WScript.Network")
Set objShell = CreateObject("WScript.Shell")
strUserName = objShell.ExpandEnvironmentStrings("%USERNAME%")
 
strDriveLetter2 = "x:"
strRemotePath2 = "\\server\xxxxx\"
 
CheckDrive = objNetwork.EnumNetworkDrives
AlreadyConnected = False
For intDrive = LBound(CheckDrive) To UBound(CheckDrive) - 1 Step 2
      If UCase(CheckDrive(intDrive)) = "x:" Then AlreadyConnected = True
Next
 
If AlreadyConnected = True Then
      objNetwork.RemoveNetworkDrive strDriveLetter2
      objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
Else
      objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
End If
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... && " & _
			"xcopy x:\localFolders " & chr(34) & _ 
                        "C:\msword\localFolders\*.*" & _
			chr(34) & " /E/D/I/R/Y", 1, true
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... && " & _
			"xcopy x:\localFolders\wordmacros " & chr(34) & _
			"c:\msword\wordmacros\*.*" & _
			chr(34) & " /E/D/I/R/Y", 1, true
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... && " & _
			"xcopy x:\localFolders\wordmacros " & chr(34) & _
			"c:\Program files\Microsoft Office\Templates\VSC Forms\*.*" & chr(34) & _
			" /E/D/I/R/Y", 1, true
 
objShell.run "%comspec% /K cOPYING MSWORD MACROS... && " & _
			"xcopy x:\localFolders\wordmacros\normal.dot " & chr(34) & _
			"c:\Program files\Microsoft Office\Templates\" & chr(34) & _
			" /y", 1, true
 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fish_itAuthor Commented:
Having a few errors 'but' a good starting point for me to teach myself VB
0
fish_itAuthor Commented:
My grading was an 'A' not a 'B' NOT SURE why it did that..... Thanks Guys...
0
RobSampsonCommented:
No problem.  Doesn't really matter.  Thanks anyway....it's the thought that counts! :-)

Regards,

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.