I have a error in my VBScript,
on line "objShell.Namespace(BackUpLoc).CopyHere objFolderItem.Path, FOF_RENAMEONCOLLISION " it is reporting that an Object is Required: "Namespace(...)".
I can't see the error, any fresh eyes?
Dim vNow, vMthStr, vDayStr, vDateStr, vHourStr, vMinuteStr, vBackupFilePath, vLogFilePath, vCmd, bCmd
Dim objShell ' as object
Dim sSrc ' as string
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Const OverWriteFiles = True
Const BackUpLoc = "C:\Backup\"
Const FOF_MULTIDESTFILES = &H1
Const FOF_CONFIRMMOUSE = &H2
Const FOF_SILENT = &H4 ' don't create progress/report
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMATION = &H10 ' Don't prompt the user.
Const FOF_WANTMAPPINGHANDLE = &H20 ' Fill in SHFILEOPSTRUCT.hNameMappings
' (Must be freed using SHFreeNameMappings)
Const FOF_ALLOWUNDO = &H40
Const FOF_FILESONLY = &H80 ' on *.*, do only files
Const FOF_SIMPLEPROGRESS = &H100 ' means don't show names of files
Const FOF_NOCONFIRMMKDIR = &H200 ' don't confirm making any needed dirs
Const FOF_NOERRORUI = &H400 ' don't put up error UI
Const FOF_NOCOPYSECURITYATTRIBS = &H800 ' dont copy NT file Security Attributes
'\\ Create Timestamp in the format yyyymmddhhmmss
vNow = Now()
vMthStr = CStr(Month(vNow))
vDayStr = CStr(Day(vNow))
vHourStr = CStr(Hour(vNow))
vMinuteStr = CStr(Minute(vNow))
' Add leading zeroes to month, day, hour, minutes
If Len(vMthStr) = 1 Then
vMthStr = "0" & vMthStr
End If
If Len(vDayStr) = 1 Then
vDayStr = "0" & vDayStr
End If
If Len(vHourStr) = 1 Then
vHourStr = "0" & vHourStr
End If
If Len(vMinuteStr) = 1 Then
vMinuteStr = "0" & vMinuteStr
End If
' Get date string in yyyymmddhhnn format.
vDateStr = Year(vNow) & vMthStr & vDayStr & vHourStr & vMinuteStr
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder to be Backup:", NO_OPTIONS, "C:\Documents and Settings\")
If objFolder Is Nothing Then
MsgBox "Backup Process Canceled", 64, "Backup Status"
WScript.quit 1
End If
If not objFolder Is Nothing Then
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
objPath = Replace(objPath, "\", "\\")
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objPath & "'")
For Each objFile in colFiles
bCmd = MsgBox ("Folder Name: " & objFolderItem.Path & (Chr(13) & Chr(10))_
& " To " & BackUpLoc & vDateStr & (Chr(13) & Chr(10)) & "Please wait for Status Message Window", 65, "Backup Folder" )
If bCmd = vbCancel Then
MsgBox "Backup Process Canceled", 64, "Backup Status"
WScript.quit 1
End If
objShell.Namespace(BackUpLoc).CopyHere objFolderItem.Path, FOF_RENAMEONCOLLISION
If ret = 0 Then
MsgBox "Backup Completed Succesfully", 64, "Backup Status"
WScript.quit(ret)
Else
MsgBox "Backup Processed Failed - Contact Support", 64, "Backup Status"
WScript.quit(ret)
End If
Next
End If
on line "objShell.Namespace(BackUpLoc).CopyHere objFolderItem.Path, FOF_RENAMEONCOLLISION " it is reporting that an Object is Required: "Namespace(...)".
I can't see the error, any fresh eyes?
Dim vNow, vMthStr, vDayStr, vDateStr, vHourStr, vMinuteStr, vBackupFilePath, vLogFilePath, vCmd, bCmd
Dim objShell ' as object
Dim sSrc ' as string
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Const OverWriteFiles = True
Const BackUpLoc = "C:\Backup\"
Const FOF_MULTIDESTFILES = &H1
Const FOF_CONFIRMMOUSE = &H2
Const FOF_SILENT = &H4 ' don't create progress/report
Const FOF_RENAMEONCOLLISION = &H8
Const FOF_NOCONFIRMATION = &H10 ' Don't prompt the user.
Const FOF_WANTMAPPINGHANDLE = &H20 ' Fill in SHFILEOPSTRUCT.hNameMappings
' (Must be freed using SHFreeNameMappings)
Const FOF_ALLOWUNDO = &H40
Const FOF_FILESONLY = &H80 ' on *.*, do only files
Const FOF_SIMPLEPROGRESS = &H100 ' means don't show names of files
Const FOF_NOCONFIRMMKDIR = &H200 ' don't confirm making any needed dirs
Const FOF_NOERRORUI = &H400 ' don't put up error UI
Const FOF_NOCOPYSECURITYATTRIBS = &H800 ' dont copy NT file Security Attributes
'\\ Create Timestamp in the format yyyymmddhhmmss
vNow = Now()
vMthStr = CStr(Month(vNow))
vDayStr = CStr(Day(vNow))
vHourStr = CStr(Hour(vNow))
vMinuteStr = CStr(Minute(vNow))
' Add leading zeroes to month, day, hour, minutes
If Len(vMthStr) = 1 Then
vMthStr = "0" & vMthStr
End If
If Len(vDayStr) = 1 Then
vDayStr = "0" & vDayStr
End If
If Len(vHourStr) = 1 Then
vHourStr = "0" & vHourStr
End If
If Len(vMinuteStr) = 1 Then
vMinuteStr = "0" & vMinuteStr
End If
' Get date string in yyyymmddhhnn format.
vDateStr = Year(vNow) & vMthStr & vDayStr & vHourStr & vMinuteStr
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder to be Backup:", NO_OPTIONS, "C:\Documents and Settings\")
If objFolder Is Nothing Then
MsgBox "Backup Process Canceled", 64, "Backup Status"
WScript.quit 1
End If
If not objFolder Is Nothing Then
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
objPath = Replace(objPath, "\", "\\")
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = '" & objPath & "'")
For Each objFile in colFiles
bCmd = MsgBox ("Folder Name: " & objFolderItem.Path & (Chr(13) & Chr(10))_
& " To " & BackUpLoc & vDateStr & (Chr(13) & Chr(10)) & "Please wait for Status Message Window", 65, "Backup Folder" )
If bCmd = vbCancel Then
MsgBox "Backup Process Canceled", 64, "Backup Status"
WScript.quit 1
End If
objShell.Namespace(BackUpLoc).CopyHere objFolderItem.Path, FOF_RENAMEONCOLLISION
If ret = 0 Then
MsgBox "Backup Completed Succesfully", 64, "Backup Status"
WScript.quit(ret)
Else
MsgBox "Backup Processed Failed - Contact Support", 64, "Backup Status"
WScript.quit(ret)
End If
Next
End If