2 Replies Latest reply on May 1, 2009 11:43 AM by philmodjunk

    FMS can't run VB Script?

    philmodjunk

      Summary

      FMS can't run VB Script?

      Description of the issue

      This appears to be a bug. The following VB script runs correctly when executed with cscript from the command line or when opening it with Microsoft Windows Base Script Host, but does not work when run as a scheduled system script from FMS 10: System Info: Windows Server 2003 sp2, FMS 10. Here's the problem: FMS 10 won't back files up across the network to another computer's drive. Information from FM inc suggests using FM Server to back up files to a local drive and then use a system level script such as VB script to copy the files to a networked drive. I created the following VB script to calculate the name of the most recent back up folder and copy all its contents to a folder that's been shared and mapped as drive Z: After testing, I put a copy of this VB script in the FMS 10 scripts directory. If I right-click the file and open it with the Microsoft base scripts host, it correctly deletes any existing filemaker files from the destination folder and then copies the files over to this destination folder from the most recent back up folder. When I use FM Server to execute this script nothing happens. Looking for any possible information, I added code to this script to log any errors/or the lack of any error to a text file in the scripts folder. Again, performing this script from the command prompt or by using MS script host, successfully copies the files and generates the text file logging each step as being performed successfully. When I ran this script from a schedule in FMS, no files were copied and the text log was not created. No errors were reported in the log viewer. *******************************************************************************************************************On Error Resume Next Bfolder = "Daily_" & Year(date) & "-" & right("0" & month(date),2) & "-" & right("0" & day(date),2) & "_1730" FolderPath = "\\BackUps\\" & Bfolder & "\\FM Server Files\\" strComputer = "." Set objFSO = CreateObject("Scripting.FileSystemObject")Set objtxtfile = objFSO.CreateTextFile("SendToZLog.txt") 'Delete current copy of file Set objWMIService = GetObject("winmgmts:" _    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") If Err then   LogErrorInfoElse  objtxtFile.Writeline ("No Error: Connect to root")End If Set colFiles = _    objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '\\FM Server BU\\' and Extension = 'FP7'") If Err then  logErrorInfoElse  objtxtFile.Writeline ("No Error: Query Shared Folder")End If For Each objFile in colFiles    objFile.Delete    If Err then       LogErrorInfo    Else       objtxtFile.Writeline (objFile.filename & " Deleted")    End IfNext 'copy most recent back up files Set colFiles = _    objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '" & FolderPath & "' and Extension = 'FP7'") If Err Then  LOgErrorInfoElse  objtxtFile.Writeline ("No Error: Query Back Up Folder")End If For Each objFile in colFiles    strNewFile = "Z:\FM Server BU\" & objFile.FileName & ".FP7"    objFile.Copy strNewFile    If Err THen       LogErrorInfo    Else       objtxtFile.Writeline ("Copied " & objfile.filename)    End IfNext objtxtfile.close Sub LogErrorInfo   objtxtFile.Writeline (Err & "  " & Err.source & ", " & Err.Description)   err.ClearEnd Sub ***********************************************************************Strangely, a simpler VB script that copies the files to a local folder on the same computer DOES work when scheduled by FM Server: *************************************************Bfolder = "Daily_" & Year(date) & "-" & right("0" & month(date),2) & "-" & right("0" & day(date),2) & "_1730" FolderPath = "\\BackUps\\" & Bfolder & "\\FM Server Files\\" strComputer = "." 'Delete current copy of file Set objWMIService = GetObject("winmgmts:" _    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colFiles = _    objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '\\Temp\\FM Server Files\\' and Extension = 'FP7'")For Each objFile in colFiles    objFile.DeleteNext 'copy most recent back up files Set colFiles = _    objWMIService.ExecQuery("Select * From CIM_DataFile Where Path = '" & FolderPath & "' and Extension = 'FP7'") For Each objFile in colFiles    strNewFile = "D:\Temp\FM Server Files\" & objFile.FileName & ".FP7"    objFile.Copy strNewFileNext