Imports System.Diagnostics Imports System.IO Module modBasicQueue Sub Main() '******************************Written by Matt Paulauskas********************************* '****************************************2010************************ ********************* Const qd = "C:\Queue\" Console.WriteLine("Waiting for file to print") Do '//continuous file check/print/delete loop If Directory.GetFiles(qd).Count > 0 Then '//Check for files...if found send to printer and delete For Each qFile As String In Directory.GetFiles(qd) '// iterate through files Try Dim psi As New ProcessStartInfo With psi .Verb = "print" .WindowStyle = ProcessWindowStyle.Hidden .FileName = qFile .UseShellExecute = True .Arguments = "/silent" . End With '// Display file being printed Console.WriteLine("Printing: " & qFile) Dim proc As New Process proc.StartInfo = psi proc.Start() Threading.Thread.Sleep(500) TryAgain: '//clean up after file has been printed Try File.Delete(qFile) Catch ex As Exception '//file was probably locked by the app resonsible for printing it '//Sleep the thread for 20ms and try again Threading.Thread.Sleep(20) GoTo TryAgain End Try '//Clean up running process Try proc.Kill() Catch ex As Exception End Try Catch ex As Exception Console.WriteLine("Print Operation: " & ex.Message) End Try Next End If '//end file check Threading.Thread.Sleep(1000) '//pause before next check Loop End Sub End Module