我有一个我在PrimalScript中编译的PDFCreator脚本,因此我可以通过svrany执行它,而我遇到的问题是,当我运行服务时,队列中永远不会看到脚本中的打印作业。如果我从我的会话中运行vbscript或编译的exe,它可以正常工作。
以下是我的vbs文件中针对pdfcreator版本2.1.1.820运行的代码
Dim strExt, intStatus, strDestFileName, strInputFileName, strReason
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set PDFCreatorQueue = CreateObject("PDFCreatorBeta.JobQueue")
strInputFileName = "C:\Temp\Test.txt"
strDestFileName = "C:\Temp\Test.pdf"
PDFProcess
' ** Sub Routine to render file as PDF
Sub PDFProcess
Dim objFolder, job, intStatPDFCreator, intPageCount
intPageCount = 1
WScript.Echo "PDF Destination Name: " & strDestFile
WScript.Echo "Initializing PDFCreator queue..."
intStatPDFCreator = PDFCreatorQueue.Initialize()
WScript.Echo "PDFCreator Object Status: " & intStatPDFCreator
If intStatPDFCreator = 0 Then
If Not objFSO.FileExists(strInputFileName) Then
WScript.Echo "PDFCreator: Can't find the file: " & strInputFileName
Else
WScript.Echo "Printing Page: " & strInputFileName
objShell.ShellExecute strInputFileName, "", "", "print"
WScript.Sleep 1000
WScript.Echo "Currently there are " & PDFCreatorQueue.Count & " job(s) in the queue"
End If
WScript.Echo "Waiting for the job to arrive at the queue..."
if Not(PDFCreatorQueue.WaitForJobs(intPageCount, 10)) Then
strReason = "The print job did not reach the queue within " & 10 & " seconds"
WScript.Echo strReason
intStatus = 0
Else
WScript.Echo "Currently there are " & PDFCreatorQueue.Count & " job(s) in the queue"
WScript.Echo "Getting job instance and merging"
PDFCreatorQueue.MergeAllJobs
while(PDFCreatorQueue.Count > 0)
Set job = PDFCreatorQueue.NextJob
WScript.Echo "Staging PDF File: " & strDestFileName
job.ConvertTo(strDestFileName)
WScript.sleep 5000
If Not(job.IsFinished Or job.IsSuccessful) Then
strReason = "Could not convert the file: " & strDestFileName
WScript.Echo strReason
intStatus = 0
Else
WScript.Echo "Job finished successfully"
End If
Wend
End If
WScript.Echo "Releasing the object"
PDFCreatorQueue.ReleaseCom()
Else
strReason = "Failed to create PDFCreator COM instance."
WScript.Echo strReason
intStatus = 0
End If
End Sub
我在我的域凭据下运行的服务,并修改了注册表以允许它以交互方式运行
SERVICE_NAME: tgprintprocessor
TYPE : 110 WIN32_OWN_PROCESS (interactive)
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 3752
FLAGS :
我已将交互式服务检测设置为运行状态。
查看PDFCreator跟踪日志我没有看到任何类型的错误。
如果我打开PDFCreator打印机并查看打印队列,我确实看到该作业命中队列并退出,甚至可以暂停打印机,以便作业在打印机队列中停止,但是com对象队列无视它的存在。
我还尝试运行PDFCreator.exe作为服务,因为我需要在背景中运行exe的实例,因为我注意到应用程序本身不会在任务管理器后期打印作业提交中启动,就像我通常看到的那样手动执行脚本。
我的问题是什么,我想我不知道还有什么地方可以查看,如果有什么我可能遗漏的东西,我可以添加到上面的测试脚本来尝试捕获问题。
答案 0 :(得分:1)
解决此问题和上述行为是将驱动程序隔离模式从默认NONE更改为SHARED。我是在Print Management Snapin下完成的。花了一段时间搞清楚......
答案 1 :(得分:0)
如果您使用的是WScript,它将在第一个wscript.echo停止。确保使用CScript运行。