Windows get default printer getting timeout error

I have an app that changes the default printer to a specific printer, prints, then changes the default printer back to it’s original printer.

Using the following to get the default printer
dim MyShell As new shell

Myshell.execute “wmic printer where default=‘TRUE’ get name”
tmpLine = Myshell.Result

And using the following to change the default printer
dim myShell as new shell

myShell.Execute “wmic printer where name=’”+NewPrinter+"’ call setdefaultprinter"

All of this works very well on an individual PC, however when trying it on a Network that is rather slow, I get a timeout error on getting the default printer and I have to pause the program for a few seconds to make sure that the default printer is changed before printing?

Does anyone know how I can 1.make sure that I can get the default printer without a timeout?
and 2. Make sure that the default printer has been changed before I print?

Shell has a Timeout property that only applies to Windows and defaults to 2 seconds.
https://documentation.xojo.com/api/os/shell.html#shell-timeout

Tim,
Thank you, I will see if 2 seconds will be enough on the specific system.

I appreciate the quick response.

2 seconds is the default. If you’re getting a timeout, you need to set it to more than 2 seconds. Try 10 seconds.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.