April 3rd, 2013, 11:13 AM
I have some experience in VBA, but in order to run scheduled tasks under Windows Server 2003 I am having to "cross-train" to VBS, and at the moment, to call it "function rich" would be a bit of a porkie!
I have a scheduled task which backs up the server to a Kingston USB device. These devices are changed daily, and cycled round.
I have written some VBS code which, after the backup completes, copies the log of the backup from its normal place to a folder on the Server which is more accessible to the Manager (who thinks I.T. is probably good for Nerds, but not normal people).
In order to further clarify the log, I have written more VBS which examines the USB devices attached to the Server, and if any attached device has one of a set of "PNPDeviceId"s, I'm trying to write it's "English" equivalent (e.g. "Backup Device 3") to the end of the copied log.
All the above code works, and gets the correct results. However, when I add the following code, the device details which are written to the end of the log just come out as a series of letter sized squares. I know I've seen something like this before, but my old brain's getting a bit bruised trying to remember where.
Can anyone help?
The code snippet follows....
'** Just create / recreate the file (normal attributes)
'** Then set the new files attributes to match the old one,
'** or to be unchanged if the file didn't exist.
objFSO.CopyFile strFullIn, strFullOut, True
.Attributes= .Attributes + binFileAttrs
'** Here's where the fun begins!
'** strPNP has a text string
'** strFullOut has the full path to the output file.
Set objFile = objFSO.OpenTextFile(strFullOut, conForAppending, True)
objFile.Write("Backup device details" & vbCrLf)
Set objFile = Nothing
Set objFSO = Nothing