Printing PDF in Windows 7 VBscript not working But XP works.

mikems2
mikems2 used Ask the Experts™
on
This script works in Windows XP but not under Windows 7 64 bit.  It seems to get stuck at the CASE  '3' idle.   It keeps looping and never gets out of idle.  Does anyone know why?  Here is part of the script.


if objFS.FileExists(filename) then
'-- Set flag if acrobat reader is running
For Each process in colProcesses
      readerActive = True
Next

'-- Get full path to PDF file
fullPath = fso.GetAbsolutePathName(fileName)

'-- Print the PDf
WScript.CreateObject ("Shell.Application") _
      .Namespace(0) _
      .ParseName( fullPath ) _
      .InvokeVerb "&Print"

'-- Get the default printer
defaultPrinter=WSHShell.RegRead("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device")
arDefaultPrinter=Split(defaultPrinter,",")

If IsArray(arDefaultPrinter) Then
      defaultPrinter=arDefaultPrinter(0)
      printerPort=arDefaultPrinter(2)
End If

wmiq = "select * from Win32_Printer where Name ='" & defaultPrinter & "'"

Do
      '-- Query status of default printer
      Set colPrinters =  objWMIService.ExecQuery(wmiq)

      '-- Check printing status of default printer
      For Each objPrinter in colPrinters
            Select Case objPrinter.PrinterStatus

                  Case 1            '-- Status Other
                        
                        If printJobStarted Then Exit Do
                  Case 2            '-- Status Unknown
                        
                        If printJobStarted Then Exit Do
                  Case 3            '-- Status Idle
                        
                        If printJobStarted Then Exit Do
                  Case 4            '-- Status Printing
                        
                        printJobStarted = True
                  Case 5            '-- Status Warming Up
                        
            End Select
      Next

      '-- Wait 100 ms
      WScript.Sleep 100

      '-- Increment our loop counter
      loopCounter = loopCounter + 1

      '-- Timeout after TIMEOUT seconds
      If loopCounter > (TIMEOUT * 10) Then Exit Do
Loop

'-- If acrobat reader wasn't active before printing, kill it
If readerActive = False Then
      '-- Query for active acrobat reader processes
      wmiq = "select * from Win32_Process where name='AcroRd32.exe'"
      Set colProcesses = wmi.ExecQuery(wmiq)

      '-- Terminate all acrobat reader processes
      For Each process in colProcesses
            process.Terminate(1)
      Next
End If
end if
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
my guess would be compatibility.  check to make sure you have the latest version of PDF.  If you don't uninstall completely using a 3rd party program like Revo Uninstaller to completely remove all registry files and program files.  Then reinstall.

Author

Commented:
Nope I have the most current version of Adobe 9.3.  This seems to be happening on all computers running windows 7.   I tested it with others running the same (windows 7).  

Author

Commented:
Anyone have anything on this yet?
Commented:
You can try to remove the "&" from the verb "&Print".

.InvokeVerb "Print"

Author

Commented:
Thanks It Worked

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial