Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Batch file to run QV in error when run in background

Hi All

I have setup a report with variables, and created a batch file to run the QV document with the variable to output the report in a PDF format. When I run my *.bat file manually it works great. It opens the QV document, send the variable and creates the pdf output. When I schedule the batch file to run through Windows 2008 64bit it just continues to give a state of running in the scheduler, starts a Qv.exe and loads it but never generates the PDF and never closes the Qv.exe.

Does anyone have any suggestions for me. I am stumped. I have spent a few days on this and not sure what to try now.

My *.bat file

call "C:\Program Files\QlikView\Qv.exe" /R /vvCreatePDF=1 /NoSecurity "D:\QVApps\Prod\Sales\EMEA.qvw"

My Macro in the QV document

'***************************************************

'Functions checks if the report should be run

'***************************************************

sub ReportCheck

set var = ActiveDocument.Variables("vCreatePDF")

val = var.GetContent.String

if val = 1 then

call CreateReports

var.SetContent 0, true

end if

End Sub

'***************************************************

'Functions creates the reports in PDF format

'***************************************************

sub CreateReports

tempFolder = "D:\DataPDF"

reportID = "RP01"

set rep = ActiveDocument.GetReport(reportID)

reportName = rep.Name

'reportName = "sdkfhjskgh"'Replace(rep.Name," ","_")

'Create the file name with path

reportFile = tempFolder & "" & reportName & " " & Date &".pdf"

'reportFile = reportName&".pdf"

'print the report

printReportPDF reportID, tempFolder 'Call the function

'Rename the report

checkOutputFile reportFile, tempFolder 'Call the function

'call ClearDefault() 'Call the function

end sub

'***************************************************

'Actual function to print the PDF format without being asked for location to save

'***************************************************

function printReportPDF(oReport, pdfLocation)

ActiveDocument.PrintReport oReport, "PDFCreator",false

set WSHShell = nothing

end function

'***************************************************

'Checks the output file before renaming the report

'***************************************************

function checkOutputFile(pdfFile,pdfLocation)

Set fileTest = CreateObject("Scripting.FileSystemObject")

'Delete any previous version of the file

if fileTest.FileExists(pdfFile) then

fileTest.DeleteFile pdfFile

End if

'Check if the temp pdf report file has been generated

strTempFile = pdfLocation & "" & "QlikView Printing.pdf"

currentStatus = fileTest.FileExists (strTempFile)

if currentStatus = false then

ActiveDocument.GetApplication.Sleep 10000

checkOutputFile pdfFile,pdfLocation

else

'rename the file

ActiveDocument.GetApplication.Sleep 10000

fileTest.MoveFile strTempFile, pdfFile

end if

set fileTest = nothing

end function

Like I mentioned when I manually run it it works, when I try to run it through Windows task scheduler it does not.

13 Replies
Not applicable
Author

Hi All

Ok with running the below batch manually it works great and i get my pdf output. (Get's to 2.9GB memory)

"C:\Program Files\QlikView\Qv.exe" /R /NoSecurity "D:\QVApps\Dev\Sales\EMEA V3.11.qvw"
"C:\Program Files\QlikView\Qv.exe" /vvCreatePDF=1 /NoSecurity "D:\QVApps\Dev\Sales\EMEA V3.11.qvw"

But when I run it through Task Sceduler it does not work. (Get's to about 0.7GB memory), just keeps satus running in Task Scheduler and does not close QV, I have to kill the process

If I run just "C:\Program Files\QlikView\Qv.exe" /R /NoSecurity "D:\QVApps\Dev\Sales\EMEA V3.11.qvw" I get nothing and it hangs on the 0.7GB memory

If I run just "C:\Program Files\QlikView\Qv.exe" /vvCreatePDF=1 /NoSecurity "D:\QVApps\Dev\Sales\EMEA V3.11.qvw" It completes but I get no PDF

Thought I would try to separate the 2 just to see if the problem was with one of them. But it seems that there is a problem between QV and task scheduler or at least running in the background. Has anybody heard of something like this before?

I took what Gordon said "I wonder if its a permissions things - when you are running it manually its a different profile to that run under the scheduler?" and I ensured that all permissions were ok. I tried running the batch as a different user and the mem usage only got to 58k think it is just opening the session... So I do not think this is it either.

I think the hang may be when it is actually first opening the qv doc judging by the timing and the memory usage.

Any ideas please?



Not applicable
Author

What happens if you run the .bat through Windows Scheduler?

Regards,

Gordon

Not applicable
Author

Hi Gordon

My QV server runs on Windows Server 2008, as above the issue is with the Windows Scheduler (Task Scheduler) as the batch files run fine when manually processed. After a few more hours and investigation I managed to succeed

The issue is with QlikView 9 SR4 and Task Scheduler Win2008 service pack 2, I purchased a low cost but great little scheduler (That runs totally independent of MS scheduler) "System Scheduler Professional" from Splinterware ($30) and I can now confirm that the batch files work 100% and I sent out my first batch of automated PDF emails last night.

Thank you to every one for their help.

suniljain
Master
Master

Just Use /l in place of /r . it will work fine . I comleted with same requirement but with PPT.