Why am I getting this error with this VB Script?

The error is

Windows Script Host
---------------------------
Script: CDocuments and Settings\cs-ads-mbb30\Desktop\arms.vbs
Line: 5
Char: 121
Error: Expected 'Then'
Code: 800A03F9
Source: Microsoft VBScript compilation error

Set shell= WScript.CreateObject("WScript.Shell")
username = shell.ExpandEnvironmentStrings("%USERNAME%")
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\Documents and Settings\" & username & "\Start Menu\Programs\End2End, Inc\ARMS V2 R3.appref-ms")
Then
Wscript.Echo "ARMS Enterprise V2 R3 is already installed for " & username & " on this
computer. Click OK to close."
Else
Wscript.Echo "ARMS Enterprise V2 R3 is not installed for " & username & " on this
computer. Please click install when prompted."
CreateObject("Wscript.Shell").Run "\\cs-metroplex.cwru.edu\ARMSInstaller\Setup.exe"
 
End If

Open in new window

FreedayAsked:
Who is Participating?
 
Lukasz ChmielewskiConnect With a Mentor Commented:
try to move then to the same line as if


Set shell= WScript.CreateObject("WScript.Shell")
username = shell.ExpandEnvironmentStrings("%USERNAME%")
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\Documents and Settings\" & username & "\Start Menu\Programs\End2End, Inc\ARMS V2 R3.appref-ms") Then
Wscript.Echo "ARMS Enterprise V2 R3 is already installed for " & username & " on this
computer. Click OK to close."
Else
Wscript.Echo "ARMS Enterprise V2 R3 is not installed for " & username & " on this
computer. Please click install when prompted."
CreateObject("Wscript.Shell").Run "\\cs-metroplex.cwru.edu\ARMSInstaller\Setup.exe"
 
End If
0
 
AsishRajCommented:
In order for the IF statement to work you need to have IF Then in one line.

You cannot have your IF Else statement like below:

IF
Then
End IF

Solution
If    then
Else
End IF


Hope this solves your problem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.