MacOS – Launch “Printer Setup Utility” from terminal

applicationsmacosprinting

Background

Trying to load the Printer Setup Utility on OSX Mavericks from the terminal. This is for a setup app which has streamlined interfaces for setting it up.

What I've Tried

I've tried going into the .app folder and loading the utility directly (./System/Library/CoreServices/Printer\ Setup\ Utility.app/Contents/MacOS/Printer\ Setup\ Utility ; )

However this merely results in a new terminal window being opened with the command being run in the foreground. Attempting to run it in the background results in no window popup, so that didn't work either. Navigating to the directory in finder and running it from there results in the same thing. So far the only way I've gotten it to run is by doing it the "proper" way of running through the System Preferences utility.

In Summary

How do I run the Printer Setup Utility from the terminal such that it opens in a window, similar to how you would open it in the GUI?

Best Answer

If you examine using ps the command launched by Printer Setup or when adding a printer through System Preferences, you'll note that it includes a -psn qualifier that directs the application as to the "process serial number" to use to communicate with the application. This effectively tells it how to connect and launch the windows necessary for the calling user/process and it's used for identifying various processes and instances of executables.

Unfortunately its unclear how -- or even if -- you'd actually use this to launch from the command line as its usage is normally invoked from within another calling application using system calls and it seems to imply that you need to create certain "Process Identification Constraints" as part of the call out.

Much of this seems to be marked up in Apple's online documentation as being Deprecated in OS X v10.9 so I'm not sure what to make of this or how to direct you for using it as Apple seems to be advising against the sorts of systems calls that utilize it moving forward. I'd expect to see the sort of calling mechanisms going away in future versions of OS X.

Further information is available at:

https://developer.apple.com/legacy/library/documentation/Carbon/Reference/Process_Manager/Reference/reference.html

and

https://developer.apple.com/legacy/library/documentation/Carbon/Reference/Process_Manager/Reference/reference.html#//apple_ref/doc/constant_group/Process_Identification_Constants

While I realize this doesn't resolve your issue, it does explain the behavior your observing and the reason why you're not getting the expected UI launching.