This is my new program
I'm glad to be with you in this lovely forum. My program is to copy the records from the file and separate it each day. I did the program program in VBScript and it's working but I faced problem in it which is copy new information on the old file I mean , if I have file for Monday it will have its own log also Thursday but my problem is put Thursday's log with Monday's log. Could you help me to find my mistake??
Dim oFSO, oFolder, sDirectoryPath
Dim oFileCollection, oFile, sDir
Dim fso
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
curdir=WSHShell.CurrentDirectory
WSHShell.CurrentDirectory="C:\Debug\tools\"
strDate = now
DelDate = now-60
' Specify Directory Path From Where You want to clear the old files
sDirectoryPath = "C:\Program Files\NCR APTRA\Advance NDC\Debug"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sDirectoryPath)
Set oFileCollection = oFolder.Files
'Check the modify date & delete
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - 1) Then
oFile.Delete(True)
End If
Next '------------------------------------------------------------
--------------------------------------------------------------------
'Convert the date to string for naming
d = CStr(day(strDate)) ++"-"++ CStr(month(strDate)) ++"-"++ right(year(strDate),2)
Dd= CStr(day(DelDate)) ++"-"++ CStr(month(DelDate)) ++"-"++ right(year(DelDate),2) '----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 'Copy the logs folder to Temp folder
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder "C:\Program Files\NCR APTRA\Advance NDC\Debug","C:\Debug\Temp",TRUE '----------------------------------------------------------------------------------------------------------------------------------------------------------------------- ' Copy the logs files to Temp folder
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\Program Files\NCR APTRA\XFS Manager\xfstrace.log") Then
filesys.CopyFile "C:\Program Files\NCR APTRA\XFS Manager\xfstrace.log", "C:\Debug\Temp\"
End If
If filesys.FileExists("C:\Program Files\NCR APTRA\Advance NDC\Gbna.ini") Then
filesys.CopyFile "C:\Program Files\NCR APTRA\Advance NDC\Gbna.ini", "C:\Debug\Temp\"
End If
'------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------
'Export event from Event Viewer & Clear it
WSHShell.Run "C:\Debug\tools\psloglist.exe -c -g ""C:\Debug\Temp\Application.evt"" Application"
WSHShell.Run "C:\Debug\tools\psloglist.exe -c -g ""C:\Debug\Temp\Security.evt"" Security"
WSHShell.Run "C:\Debug\tools\psloglist.exe -c -g ""C:\Debug\Temp\System.evt"" System" '------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------
wscript.sleep(10000)
'Add Temp folder to zip file
strfile = "zip C:\Debug\" ++ d ++ ".zip -m ""C:\Debug\Temp\*.*"""
WSHShell.Run strfile, 2, false '-----------------------------------------------------------------------------------------
------------------------------------------------------------------------------
'Delete the old Zip file
If filesys.FileExists("C:\Debug\" ++ Dd ++ ".zip") Then
Set aFile = fso.GetFile("C:\Debug\" ++ Dd ++ ".zip")
aFile.Delete
End If
Set fso = Nothing
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
Set WSHShell = Nothing
WScript.Quit(0)
Dim oFSO, oFolder, sDirectoryPath
Dim oFileCollection, oFile, sDir
Dim fso
Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
curdir=WSHShell.CurrentDirectory
WSHShell.CurrentDirectory="C:\Debug\tools\"
strDate = now
DelDate = now-60
' Specify Directory Path From Where You want to clear the old files
sDirectoryPath = "C:\Program Files\NCR APTRA\Advance NDC\Debug"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sDirectoryPath)
Set oFileCollection = oFolder.Files
'Check the modify date & delete
For each oFile in oFileCollection
If oFile.DateLastModified < (Date() - 1) Then
oFile.Delete(True)
End If
Next '------------------------------------------------------------
--------------------------------------------------------------------
'Convert the date to string for naming
d = CStr(day(strDate)) ++"-"++ CStr(month(strDate)) ++"-"++ right(year(strDate),2)
Dd= CStr(day(DelDate)) ++"-"++ CStr(month(DelDate)) ++"-"++ right(year(DelDate),2) '----------------------------------------------------------------------------------------------------------------------------------------------------------------------- 'Copy the logs folder to Temp folder
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder "C:\Program Files\NCR APTRA\Advance NDC\Debug","C:\Debug\Temp",TRUE '----------------------------------------------------------------------------------------------------------------------------------------------------------------------- ' Copy the logs files to Temp folder
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\Program Files\NCR APTRA\XFS Manager\xfstrace.log") Then
filesys.CopyFile "C:\Program Files\NCR APTRA\XFS Manager\xfstrace.log", "C:\Debug\Temp\"
End If
If filesys.FileExists("C:\Program Files\NCR APTRA\Advance NDC\Gbna.ini") Then
filesys.CopyFile "C:\Program Files\NCR APTRA\Advance NDC\Gbna.ini", "C:\Debug\Temp\"
End If
'------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------
'Export event from Event Viewer & Clear it
WSHShell.Run "C:\Debug\tools\psloglist.exe -c -g ""C:\Debug\Temp\Application.evt"" Application"
WSHShell.Run "C:\Debug\tools\psloglist.exe -c -g ""C:\Debug\Temp\Security.evt"" Security"
WSHShell.Run "C:\Debug\tools\psloglist.exe -c -g ""C:\Debug\Temp\System.evt"" System" '------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------
wscript.sleep(10000)
'Add Temp folder to zip file
strfile = "zip C:\Debug\" ++ d ++ ".zip -m ""C:\Debug\Temp\*.*"""
WSHShell.Run strfile, 2, false '-----------------------------------------------------------------------------------------
------------------------------------------------------------------------------
'Delete the old Zip file
If filesys.FileExists("C:\Debug\" ++ Dd ++ ".zip") Then
Set aFile = fso.GetFile("C:\Debug\" ++ Dd ++ ".zip")
aFile.Delete
End If
Set fso = Nothing
Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing
Set WSHShell = Nothing
WScript.Quit(0)
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.