Printing by VBS - Windows 2008 R2 Server

0

Hello

I made an automatic print routine where a task that I created in windows server 2008 R2 calls a vbs script, where it is done an HTTP request by GET to a web service that assembles a PDF file in a folder. Hence the same script after mounting the file, sends it to the printer installed as the default printer on the server and it is printed, and then the uploaded file is deleted from the server in order to not take up disk space. However, the script only works when I run it manually, ie the task scheduler of windows server 2008 R2, the script runs (I realized this because I noticed that the file is deleted, as I mentioned above) but does not send the file and does not return any errors. Anyone have any idea what it is? Here 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
    
asked by anonymous 06.11.2018 / 17:40

1 answer

0

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

    
06.11.2018 / 18:37