troubleshooting Question

vbs script to automate printing HELP PLEASE

Avatar of bhgewilson
bhgewilsonFlag for United States of America asked on
Programming
1 Comment1 Solution377 ViewsLast Modified:
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.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros