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