G
G
ganbatte2018-11-15 04:29:06
VBScript
ganbatte, 2018-11-15 04:29:06

There is a vps script that prints pdf files from a folder. But that default program for pdf comes out all the time, how to fix it?

Here is the script itself.

Option Explicit : Dim objWord, objDoc, wssh, objFS, objShell, objPath, objFolder, objItem
 
Set wssh = CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objPath = objFS.GetFolder("C:\Folder\") 'Папка, из которой файлы отправляются на печать
 
Do
  PrintDelInFolder objPath
  WScript.Sleep 1000 ' Частота проверки папки -- 1 секунда 
Loop
 
Sub PrintDelInFolder(objFolder)
    For Each objItem In objFolder.Files
        If StrComp(objFS.GetExtensionName(objItem.Name), "pdf", vbTextCompare) = 0 Then
                With wssh
            WScript.Sleep 1000
                    On Error Resume Next
            dim f
            f = Cstr(objItem.Path+".pdf")
            objFS.MoveFile objItem.Path, f
            If err.number=0 then 
                Set objShell = CreateObject("Shell.Application")        
                objShell.ShellExecute f, "vbHide", "", "print", 0
                set objShell = nothing
                err.Clear
                Do
                WScript.Sleep 5000
                objFS.DeleteFile f ,true 
                        Loop While objFS.FileExists(f)
                err.Clear
            End If
            On Error Goto 0
        End With
        End If
    Next
End Sub
WScript.Quit 0

At first there was such an error 5beccb7e4538d234597819.png
Then I installed adobe acrobat. And it worked, but with every print, this program starts. How can I make it not show up? or are there other solutions? I did it according to this manual
Link to source

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2018-11-15
@ganbatte

Sumatra PDF Able to print from the command line, without creating additional windows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question