Nosmas
New member
Although I am fairly new to VBS I have successfully modified a Macrium Reflect generated script for backups of my system, but now wish to enhance the script and to write (log) entries to a text file. Each time the backup is run I want to create a new text file and to differentiate between files by incorporating the date (and possibly the time) in the file title. The following is an extract which is giving me a problem: -
1 OPTION EXPLICIT
2 Dim objFSO, objLog, today, strLogFileName
3
4 today = Date()
5 wscript.echo today
6 strLogFileName = "Backup-log " & today
7 wscript.echo strLogFileName
8
9 Set ObjFSO = CreateObject("Scripting.FileSystemObject")
10 Set objLog = objFSO.CreateTextFile("c:\Users\Peter\Desktop\" & strLogFileName & ".txt")
The line numbers are of course NOT part of the script. The echo's at lines 5 and 7 are purely to ensure that the correct parameters are being constructed and will not be included when the script finally runs, and Desktop will eventually be replaced by a different folder. Line 10 is giving a runtime error of 'Path not found'. Can someone please advise me what I have done wrong in this script?
1 OPTION EXPLICIT
2 Dim objFSO, objLog, today, strLogFileName
3
4 today = Date()
5 wscript.echo today
6 strLogFileName = "Backup-log " & today
7 wscript.echo strLogFileName
8
9 Set ObjFSO = CreateObject("Scripting.FileSystemObject")
10 Set objLog = objFSO.CreateTextFile("c:\Users\Peter\Desktop\" & strLogFileName & ".txt")
The line numbers are of course NOT part of the script. The echo's at lines 5 and 7 are purely to ensure that the correct parameters are being constructed and will not be included when the script finally runs, and Desktop will eventually be replaced by a different folder. Line 10 is giving a runtime error of 'Path not found'. Can someone please advise me what I have done wrong in this script?
My Computer
- Computer type
- PC/Desktop
- Computer Manufacturer/Model Number
- Dell Optiplex 9030
- OS
- Microsoft Windows 10 Pro 64-bit Multiprocessor
- CPU
- Intel(R) Core(TM) i3-4160 CPU @3.60 GHz x 4
- Memory
- 4.00 GB
- Monitor(s) Displays
- 23-inch full-HD WLED
- Screen Resolution
- 1920 x 1080 @ 60 Hz
- Hard Drives
- 1 x 2.5-inch SATA hard drive
- PSU
- 185 Watt
- Browser
- MS Edge and IE 11
