Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question