Printing by VBS - Windows 2008 R2 Server

Asked

Viewed 121 times

1

Hello!

I did an automatic print routine where a task I created in windows server 2008 R2 calls a vbs script, where HTTP request by GET is made to a web service that mounts a PDF file in a folder. Hence the same script after mounting the file, sends the same to the printer installed as default printer on the server and the same is printed, and then the file sent is deleted from the server in order not to occupy disk space. However, the script only works when I run it manually, IE, by task scheduler windows server 2008 R2, the script runs ( I noticed this because I found that the file is deleted as I mentioned above) but does not send the file for printing and also does not return any error. Does anyone have any idea what it is? Below is my VBS script:

Dim oXMLHTTP
Dim oStream

Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")

oXMLHTTP.Open "GET", "http://localhost/web/solicitacao_temporaria/imprimir", False
oXMLHTTP.Send

If oXMLHTTP.Status = 200 Then

TargetFolder = "C:\solicitacoes" 

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.Namespace(TargetFolder)

Set colItems = objFolder.Items


For Each objItem in colItems
    set oWsh = CreateObject ("Wscript.Shell")
    oWsh.run """C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"" /p /h C:\solicitacoes\" & objItem & ".pdf" ,,true
Next
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.DeleteFile("C:\solicitacoes\*.*"), DeleteReadOnly

Else
    MsgBox(oXMLHTTP.Status)

End If

1 answer

0

I just went through this problem in an application developed in Delphi. The problem had nothing to do with the code. It was simply a matter of configuring which program the file should be opened with (that same Windows configuration). Try there and configure to open with the Acrobat Reader that you have on your machine. Mine was configured to open with the browser.

  • Marcelo, thank you for your attention, but I had already been through this problem, so much so that in the line oWsh.run ""C: Program Files (x86) Adobe Reader 10.0 Reader Acrord32.exe"" /p /h C: solicitacoes" & objItem & ". pdf" ,,,true , it configures to open the Acrobat Reader that is installed on the server .

Browser other questions tagged

You are not signed in. Login or sign up in order to post.