seaninman
asked on
VB Script will not run on Windows 2008
I have these 2 script that I use to add and remove files daily from a file share. For some reason this scripts will not run on Windows 2008. Any thoughts??
Removal script below, and copy files script attached...
Dim sFolderPath : sFolderPath = "\\server\share" 'set folder path here
Dim oFso: Set oFso = CreateObject("Scripting.Fi leSystemOb ject")
Dim oFolder : Set oFolder = oFso.GetFolder(sFolderPath )
Dim cFiles : Set cFiles = oFolder.Files
For Each ofile In cFiles
oFso.DeleteFile ofile.path
Next
Removal script below, and copy files script attached...
Dim sFolderPath : sFolderPath = "\\server\share" 'set folder path here
Dim oFso: Set oFso = CreateObject("Scripting.Fi
Dim oFolder : Set oFolder = oFso.GetFolder(sFolderPath
Dim cFiles : Set cFiles = oFolder.Files
For Each ofile In cFiles
oFso.DeleteFile ofile.path
Next
strComputer = "."
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim SizeCount
Const ForAppending = 8
Const ForWriting = 2
Const ForReading = 1
WorkingDate = Date
DateFormated = Replace(WorkingDate,"/","-")
DateSplit = Split(DateFormated,"-")
DateMonth = DateSplit(0)
DateDay = DateSplit(1)
DateYear = DateSplit(2)
DateFinal = DateMonth & "-" & DateDay & "-" & DateYear
Yesterday = Date - 1
YesterdayFormated = Replace(Yesterday,"/","-")
'WScript.Echo YesterdayFormated
YesterdaySplit = Split(YesterdayFormated,"-")
YesterdayMonth = YesterdaySplit(0)
YesterdayDay = YesterdaySplit(1)
YesterdayYear = YesterdaySplit(2)
YesterdayFinal = YesterdayMonth & "-" & YesterdayDay & "-" & YesterdayYear
'WScript.Echo "yesterday = " & YesterdayFinal
'WScript.Echo "Today's Date: " & datefinal
objStartFolder = "\\server\share"
objDestinationFolder = "\\server\share1"
Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile in colFiles
'Wscript.Echo objFile.Name
If objFile.Name = "Daily Report " & DateFinal & ".pdf" Then
'WScript.Echo "file found"
'WScript.Echo objStartFolder & "\" & objFile.Name,objDestinationFolder & "\" & objFile.Name,True
objfso.CopyFile objStartFolder & "\" & objFile.Name,objDestinationFolder & "\" & objFile.Name,True
If objfso.FileExists (objDestinationFolder & "\CRS Daily Report " & YesterdayFinal & ".pdf") Then
'WScript.Echo "old file found"
objfso.DeleteFile objDestinationFolder & "\Daily Report " & YesterdayFinal & ".pdf"
End If
End If
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
'Wscript.Echo Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
'Wscript.Echo objFile.Name
If objFile.Name = "Daily Report " & DateFinal & ".pdf" Then
'WScript.Echo "file found"
objfso.CopyFile Subfolder.Path & "\" & objFile.Name,objDestinationFolder & "\" & objFile.Name,True
If objfso.FileExists (objDestinationFolder & "\Daily Report " & YesterdayFinal & ".pdf") Then
objfso.DeleteFile objDestinationFolder & "\Daily Report " & YesterdayFinal & ".pdf"
End If
End If
Next
'Wscript.Echo
ShowSubFolders Subfolder
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No other solutions provided.
~bp