?
Solved

Why am I getting this error with this VB Script?

Posted on 2009-02-11
2
Medium Priority
?
604 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:Freeday
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 200 total points
ID: 23614815
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
 
LVL 9

Expert Comment

by:AsishRaj
ID: 23646543
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 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