Hi All,
I am trying to modify the script since file placed under C:\folder will be 2 hours older file. For example at 10 AM the file name will be log-data-29-08-2013-08.log and at 12:00 AM the file name will be log-data-28-08-2013-22.log. This is used for file monitoring under SCOM. When I compile it says CTSFileExistingMonitor1.vbs(144, 7) Microsoft VBScript compilation error: Expected 'End'Dim CurrentDate, Name, FileName, Path, FullPath, oAPI
Path = "c:\folder"
Set oAPI = CreateObject("MOM.ScriptAPI")
d= right("0" & day(date()),2)
m= right("0" & month(date()),2)
y= right("" & year(date()),4)
h= right("" & hour(time()),2)
If h=00 Then
T=22
d= right("0" & day(date()-1),2)
If d=0 then
D= right("0" & day(date()-1),2)
If m=1 then
M= right("0" & month(date()-1),2)
Y= right("" & year(date()-1),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
Else
D= right("0" & day(date()-1),2)
M= right("0" & month(date()),2)
Y= right("" & year(date()),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
End If
Else
D= right("0" & day(date()-1),2)
M= right("0" & month(date()),2)
Y= right("" & year(date()),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
End If
Else If h=01 Then
T=23
d= right("0" & day(date()-1),2)
If d=0 then
D= right("0" & day(date()-1),2)
If m=1 then
M= right("0" & month(date()-1),2)
Y= right("" & year(date()-1),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
Else
D= right("0" & day(date()-1),2)
M= right("0" & month(date()),2)
Y= right("" & year(date()),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
End If
Else
D= right("0" & day(date()-1),2)
M= right("0" & month(date()),2)
Y= right("" & year(date()),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
End If
Else If h<12 Then
t=h-2
T="0" & t
D= right("0" & day(date()),2)
M= right("0" & month(date()),2)
Y= right("" & year(date()),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
Else
T=h-2
D= right("0" & day(date()),2)
M= right("0" & month(date()),2)
Y= right("" & year(date()),4)
CurrentDate = D &"-"& M &"-"& Y & "-" & T
FileName = "log-data-" & CurrentDate & ".log"
FullPath = Path &"\"& FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oBag = oAPI.CreatePropertyBag()
If objFSO.FileExists(FullPath) Then
Call oBag.AddValue("Status", "YES")
Else
Call oBag.AddValue("Status", "NO")
End If
Call oAPI.Return(oBag)
End If