Get Expected "End" error in vb script on last line Char: 8 does anyone
know why?

Thanks!

Glenn
***************************************************************************

Dim wshShell, wshNetwork, OS_Ver, CRLF, oFSO, hoFSO, GroupDict,
CCMINSTPATH
CRLF = Chr(13) & Chr(10) ' use for return and line carriage
Set wshNetwork = WScript.CreateObject("WScript.Network")
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
TempPath = wshShell.ExpandEnvironmentStrings("%TEMP%")
UserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")
ComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Set WshShell = Wscript.CreateObject("Wscript.Shell")
strMapperSetting = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{5FF8D3B8-E19A-4B74-A430-A5366CA74B3F}\InstallSource")
if strMapperSetting = "\\ccl_applib\msipackages\mapper\" then
message = "value exists"
If oFSO.FileExists(".\dataexist.010") then
oFSO.DeleteFile(".\dataexist.010")
End if
If Err.Number <> 0 Then ' value does not exists
strMapperSettingExists = 0
Else
strMapperSettingExists = 1
End If

if strMapperSettingExists = 1 then
writelog message
end if
wscript.quit

'===================================================================================
'***************************** Subroutine to write to file
*************************
'===================================================================================

Sub WriteLog (strMessage)

const ForRead = 1
const ForWrite = 2
const ForAppend = 8

LogFile = ".\dataexist.010"

Set fsLog = oFSO.OpenTextFile(LogFile, 8, True)
fsLog.WriteLine (strMessage)
fsLog.Close
end sub

Re: Error Expected End by Ray

Ray
Mon Oct 20 17:34:56 CDT 2003

You're missing an End If. Look at your code closely. Here's a trimmed
version:

if strMapperSetting = "\\ccl_applib\msipackages\mapper\" then
message = "value exists"
If oFSO.FileExists(".\dataexist.010") then
oFSO.DeleteFile(".\dataexist.010")
End if

If Err.Number <> 0 Then ' value does not exists
strMapperSettingExists = 0
Else
strMapperSettingExists = 1
End If

if strMapperSettingExists = 1 then
writelog message
end if

END IF <--- THIS DOES NOT EXIST

Although, I imagine you don't really want that end if there at the end.
Either put it at the top, or put your first if/then all on one line.

Ray at home


"glenn aurelius" <glenna@carnival.com> wrote in message
news:ca5d3524.0310201342.3bb4a224@posting.google.com...
> Get Expected "End" error in vb script on last line Char: 8 does anyone
> know why?
>
> Thanks!
>
> Glenn
>
***************************************************************************
>
> Dim wshShell, wshNetwork, OS_Ver, CRLF, oFSO, hoFSO, GroupDict,
> CCMINSTPATH
> CRLF = Chr(13) & Chr(10) ' use for return and line carriage
> Set wshNetwork = WScript.CreateObject("WScript.Network")
> Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
> TempPath = wshShell.ExpandEnvironmentStrings("%TEMP%")
> UserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")
> ComputerName = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
> Set WshShell = Wscript.CreateObject("Wscript.Shell")
> strMapperSetting =
WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{
5FF8D3B8-E19A-4B74-A430-A5366CA74B3F}\InstallSource")
> if strMapperSetting = "\\ccl_applib\msipackages\mapper\" then
> message = "value exists"
> If oFSO.FileExists(".\dataexist.010") then
> oFSO.DeleteFile(".\dataexist.010")
> End if
> If Err.Number <> 0 Then ' value does not exists
> strMapperSettingExists = 0
> Else
> strMapperSettingExists = 1
> End If
>
> if strMapperSettingExists = 1 then
> writelog message
> end if
> wscript.quit
>
>
'===========================================================================
========
> '***************************** Subroutine to write to file
> *************************
>
'===========================================================================
========
>
> Sub WriteLog (strMessage)
>
> const ForRead = 1
> const ForWrite = 2
> const ForAppend = 8
>
> LogFile = ".\dataexist.010"
>
> Set fsLog = oFSO.OpenTextFile(LogFile, 8, True)
> fsLog.WriteLine (strMessage)
> fsLog.Close
> end sub



Re: Error Expected End by Adam

Adam
Mon Oct 20 17:30:55 CDT 2003

In article <ca5d3524.0310201342.3bb4a224@posting.google.com> "glenn aurelius"
<glenna@carnival.com> wrote in microsoft.public.scripting.vbscript:
> Get Expected "End" error in vb script on last line Char: 8 does anyone
> know why?

The first thing you want to do in these cases is to make sure that
anything you `begin' is `ended'. A quick scan through your code reveals
the following:

[...]
> if strMapperSetting = "\\ccl_applib\msipackages\mapper\" then
> message = "value exists"

Assuming that is actually two lines of source, where's the `End If'?
You've opened one more If block than you've closed.

hth

Adam
--
Q: How many surrealists does it take to change a light bulb?
A: Two, one to hold the giraffe, and the other to fill the bathtub
with brightly colored machine tools.