[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

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.FileSystemObject")
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

Open in new window

0
seaninman
Asked:
seaninman
  • 2
1 Solution
 
Bill PrewCommented:
What happens when you run it, do you get any errors, etc?

~bp
0
 
seaninmanAuthor Commented:
says cant find path... but when i run it on an XP machine works perfectly
0
 
seaninmanAuthor Commented:
No other solutions provided.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now