bhgewilson
asked on
vbs script to automate printing HELP PLEASE
I have asked this before and almost got it worked out but here goes.
The backup is scheduled daily at 11:00 PM and writes a file for that backup log. It goes from backup01-backup10 and overwrites after ten days. It doesn't start in any particular order so I never know what backup log to print. I want to automate so each day the backup log prints the latest log a printer. I want to setup a batch file that automatically prints the newest file.
I have setup a vbs file from another post but it doesn't work. I will post it here. I thought it worked but it does not. I will end up replacing logs with the path for the backup logs but that is all. I am desperate to get this resolved. Please help.
Dim LatestDate, MyCmd
Set Shell = CreateObject("Wscript.Shel l")
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set FS = objFSO.GetFolder("C:\logs" )
For Each fl In FS.Files
If FL.DateCreated > LatestDate Then
set NewestFile = fl
LatestDate = fl.DateCreated
end if
Next
If Not NewestFile is nothing Then
'NewestFile = chr(34) & NewestFile & Chr(34)
MyCmd = "cmd /c copy " & NewestFile & " lpt2"
Shell.Run MyCmd
end If
Thanks,
Brad
The backup is scheduled daily at 11:00 PM and writes a file for that backup log. It goes from backup01-backup10 and overwrites after ten days. It doesn't start in any particular order so I never know what backup log to print. I want to automate so each day the backup log prints the latest log a printer. I want to setup a batch file that automatically prints the newest file.
I have setup a vbs file from another post but it doesn't work. I will post it here. I thought it worked but it does not. I will end up replacing logs with the path for the backup logs but that is all. I am desperate to get this resolved. Please help.
Dim LatestDate, MyCmd
Set Shell = CreateObject("Wscript.Shel
Set objFSO = CreateObject("Scripting.Fi
Set FS = objFSO.GetFolder("C:\logs"
For Each fl In FS.Files
If FL.DateCreated > LatestDate Then
set NewestFile = fl
LatestDate = fl.DateCreated
end if
Next
If Not NewestFile is nothing Then
'NewestFile = chr(34) & NewestFile & Chr(34)
MyCmd = "cmd /c copy " & NewestFile & " lpt2"
Shell.Run MyCmd
end If
Thanks,
Brad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.