[1] Correction
>[self]Add overwrite flag to true, else repeated execution will be a runtime error.
This is incorrect, my fault. After checking the documentation again, the default of overwrite flag is true, so omitting that flag is okay and will not result in runtime by repeated execution. So with or without true flag is fine as long as it is not false.
[2] There is another typo.
>ldFile = oFile.DataLastModified
[tt]ldFile = oFile.Dat[red]e[/red]LastModified[/tt]
[3] I must confess I still cannot figure out whether eventual working or not for you. In any case, this is one possible cleanup version where some info not fully used is left untouched.
[tt]
Dim FSO, NotesID, objNetwork, strUserName, ldFile
set FSO = WScript.Createobject ("Scripting.FileSystemObject")
set objNetwork = CreateObject ("WScript.Network")
strUserName = objNetwork.UserName
NotesID = "C:\Lotus\Notes\Data" & strUserName & ".id"
if FSO.fileexists(NotesID) then
set oFile = FSO.GetFile (NotesID)
ldFile = oFile.DateLastModified
FSO.CopyFile NotesID, "C:\NotesBackup"
set oFile=nothing
else
wscript.echo "file: " & NotesID & " cannot be found."
end if
set objNetwork=nothing
set FSO=nothing
[/tt]
The destined file is name "NotesBackup" (not a foldername). But if there exists a folder named c:\NotesBackup, it is a runtime error. This will be the only main source of error untreated in the script. You can check the existence of it before issuing copyfile instruction. Like this.
[tt]
if FSO.folderexists("C:\NotesBackup") then
wscript.echo "Warning: backup filename collides with an existing folder. Operation aborted."
else
FSO.CopyFile NotesID, "C:\NotesBackup"
end if
[/tt]
I feel over-elaborated on simple thing!