Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Fix HP Communications and Fast User Switching System
HP multifunction devices are accompanied by boneheaded OS X drivers. In particular, stuff fails unless the current user has a working verion of the background app "HP Communications." A previous hint explained how to deal with the fact that this app does not necessarily play nicely with sleep mode. In this hint, I explain how to make the app work with Fast User Switching.

Begin by installing WinSwitch (the Win comes not from Microsoft but from the first name -- Wincent -- of the developer). This is a freeware (but do consider donating!) MenuExtra that replaces Apple's own Fast User Switching menu. The nice thing about WinSwitch is (besides being, IMO, well-written) that it listens for notifications of NSWorkspaceSessionDidResignActiveNotification and NSWorkspaceSessionDidBecomeActiveNotification. WinSwitch will automatically run items found in ~/Library -> Application Support -> WinSwitch -> Switch-In Items and ~/Library -> Application Support -> WinSwitch -> Switch-Out Items by using the equivalent of double-clicking them in the Finder ([[NSWorkspace sharedWorkspace] openFile:itemPath], if you care to know). We use this to automatically quit HP Communications for the user switching out, and start it for the user switching in.

First, create ~/Library -> Application Support -> WinSwitch -> Switch-In Items -> StartHP.command, containing the following script:
#!/bin/sh
#ac
# wakeup: start HP Commmunications process
#
open /Library/Printers/hp/HP Communications.app
and then do a chmod 755 Library/Application Support/WinSwitch/Switch-In Items/StartHP.command to make it executable. Now create ~/Library -> Application Support -> WinSwitch -> Switch-Out Items -> Kill_HPCommunications.command, containing:
#!/bin/sh
#
# kill HP Communications process
#
kill -HUP `ps axwww | egrep -i 
"/Library/Printers/hp/HP Communications.app" | egrep -iv 
"egrep -i" | awk '{print $1}'`
killall pipedaemon
and again change the permissions by typing chmod 755 ~/Library/Application Support/WinSwitch/Switch-Out Items/Kill_HPCommunications.command [/code] Now log in or switch to all the other users, and create the same scripts. If you want to keep the scripts in a central location and symlink to them, that should work, but you must ensure that the metadata causes the commands to run (rather than, say, open in an editor) when you double-click them. While you are switched in as the other users, take a minute to run /Users -> Shared -> Activate WinSwitch.command, to get WinSwitch working for them as well.

I am successfully using this with an OfficeJet 4215, but I imagine it works with the entire 4200 series and probably all HP all-in-ones. I have three caveats:
  1. This tends to leave Terminal windows around with exit'ed process notifications in them. You can fix that with Window Settings (Shell) in Terminal by telling it to close windows on exit'ed processes, but it's easy to "Use As Default" and end up running the script every time you open a Terminal window (fixable by editing Terminal's preferences plist)!
  2. It is important to activate WinSwitch and create the scripts for every user involved in switching.
  3. I am not sure how this interacts with sleep problems, as I have not encountered any.
As mentioned in the comments on the sleep hint, it is quite possible all the grepping and awking in the kill script could be replaced with killall. Just make sure you kill only the process you want to! Also, if anyone wants to comment on an easy way to avoid leaving those Terminal windows scattered around, that would be nice.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,328 views]  

Fix HP Communications and Fast User Switching | 10 comments | Create New Account
Click here to return to the 'Fix HP Communications and Fast User Switching' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fix HP Communications and Fast User Switching
Authored by: klktrk on Oct 18, '04 12:45:43PM

I would imagine that if you didn't use the .command extension, but rather a shell script extension (such as .sh) for your shell scripts, that the commands would run without opening up a terminal window. The .command extension is registered to Terminal.



[ Reply to This | # ]
Fix HP Communications and Fast User Switching
Authored by: brianboonstra on Oct 25, '04 05:38:38PM
I had thought so too, but as it turned out, the fact that I had written the scripts in SubEthaEdit meant that SEE was listed as the Creator. Hence, the open command opened the scripts in SEE rather than running them. Metadata hell!

Now, perhaps if one created the scripts in pico or just with a quick cat, the right thing would happen. But I suspect not.

An applescript app might be a better way. Or, one could use the source from WinSwitch as a guide to writing a tool that simply does the right thing.

[ Reply to This | # ]
Fix HP Communications
Authored by: barryjaylevine on Oct 18, '04 01:05:25PM

If you don't "switch users", there is still another problem with the HP Director app. If you turn off the PSC device, scanning is no longer possible unless you quit the HP Communications app which is a background, invisible app with no user interface (and no way to force-quit it). I've written an app (called "HP Comm Killer") which will quit this app and permit you to scan without having to re-boot your Mac. It's freeware and may be found here:

http://www.macupdate.com/info.php/id/15456

Barry

---
-----
Honda Reflex - Riding a 60mpg scooter is your patriotic duty!



[ Reply to This | # ]
Fix HP Communications
Authored by: PygmySurfer on Oct 19, '04 06:40:14AM

I have an OfficeJet 6110, and I've never experienced the problem you've described. I'm using the HP All-In-One software version 6.3.4.



[ Reply to This | # ]
Fix HP Communications
Authored by: barryjaylevine on Oct 19, '04 06:01:07PM

I should not have painted the problem with such broad strokes. Only some of the units using the HP Communications exhibit this problem; the PSC 1210 is one (and users of the 1315 and 1350 report this problem, as well).


---
-----
Honda Reflex - Riding a 60mpg scooter is your patriotic duty!



[ Reply to This | # ]
Fix HP Communications
Authored by: Shawn Parr on Jan 29, '05 09:52:28AM

My Photosmart 7135 also has this issue.



[ Reply to This | # ]
Fix HP Communications and Fast User Switching
Authored by: reynolds5520 on Jan 09, '05 01:56:47PM
When I tried to set the script files to executable I got errors until I realized the path names include spaces. Terminal requires single quotes around the path name (as below) when there are spaces. Hope this saves somebody some effort...
chmod 755 '~/Library/Application Support/WinSwitch/Switch-In Items/StartHP.command'
chmod 755 '~/Library/Application Support/WinSwitch/Switch-Out Items/Kill_HPCommunications.command'


[ Reply to This | # ]
Fix HP Communications and Fast User Switching
Authored by: reynolds5520 on Feb 06, '05 03:50:06PM
After testing various scripts for killing/starting the HPCommunications.APP, I finally found a solution that gets this job done without leaving shell windows open (or hanging for long timeout periods). The trick is to make it an applescript application that performs a shell script within the applescript. To be certain that the script killed HP when I wanted it killed and started it when I wanted it to start I made a script for each. I used ideas from the hint above and other sources. I hope I haven`t failed to credit anyone... Paste each of the texts below into a new applescript script editor window and save as an application. Place the applications in the switch-in and switch-out folders as appropriate.

*********first script starts here**********************


-- Start_HP_Communications by Kevin Reynolds   (c) 2005




do shell script "#!/bin/sh
		#ac
		# wakeup: start HP Commmunications process
		#
		open '/Library/Printers/hp/HP Communications.app'"






-- From DealWithHP by Adam Christianson  (see end for credits)

-- This script is for use with HP All-In-One (AIO) Printer/Fax/Scanner
-- with OS X Fast User Switching

-- Under fast user switching each user runs a new copy of the
-- printer USB driver called "HP Communications.app"

-- Only one copy can run at a time or printer communications will fail

-- Use this script with WinSwitch to restart HP Communications when
-- switching into one user and out from another.

--Place this script in: ~/Library/Application Support/WinSwitch/Switch-In Items
--for each user.



-- DealWithHP.applescript
-- DealWithHP

--  Created by Adam Christianson on Tue Dec 03 2002.
--  Copyright (c) 2002 Terraform Creative. All rights reserved.




********************ends here*********************




********************second script starts here*****************


-- Kill_HP_Communications by Kevin Reynolds   (c) 2005


-- From DealWithHP by Adam Christianson  (see end for credits)

-- This script is for use with HP All-In-One (AIO) Printer/Fax/Scanner
-- with OS X Fast User Switching

-- Under fast user switching each user runs a new copy of the
-- printer USB driver called "HP Communications.app"

-- Only one copy can run at a time or printer communications will fail

-- Use this script with WinSwitch to kill HP Communications when
-- switching out of one user and into another.

--Place this script in: ~/Library/Application Support/WinSwitch/Switch-Out Items
-- for each user.


tell application "Finder"
	if (get name of every process) contains "HP Communications" then

		tell application "HP Communications" to quit

	end if
end tell



-- DealWithHP.applescript
-- DealWithHP

--  Created by Adam Christianson on Tue Dec 03 2002.
--  Copyright (c) 2002 Terraform Creative. All rights reserved.


*********ends here**************************


[ Reply to This | # ]
Fix HP Communications and Fast User Switching
Authored by: sig eigei on May 31, '05 07:12:41PM

Is there a way to make one script that checks to see if HP Communications is active or not and then executes the proper command? I treid to fashion something together from
http://www.macosxhints.com/comment.php?mode=display&sid=20041104142244497&title=Simpler+Script&pid=48455
but the script got stuck whenever it found it needed to activate HP Communications. Any ideas? I will try to the two scripts with Winswitch and see if I can get them going.



[ Reply to This | # ]
Restarting Stuck HP Communications
Authored by: BMarsh on Apr 12, '05 09:11:56PM

I posted this in the Earlier Thread with HP Communications and Sleep in 10.3 (http://www.macosxhints.com/article.php?story=2004091919244039)

not sure how many have had this problem, but sometimes my mothers HP LaserJet 3330 MFP will just die, sometimes this just requires doing a Force Quit on the HP Communications.app, then start it up again.

Other Times, the 3330 itself needs to be powered off, then back on, and then have this Force Quit and relaunch happen (or a restart of the computer as well)

I developed the following applescript for my mother who had trouble remembering the steps, or losing the written instructions to do this, now it is one click on the dock.

[code]
set thePID to 0

set thePID to do shell script "ps axww | egrep -i '/Library/Printers/hp/HP Communications' | egrep -iv 'egrep -i' | awk '{ print $1 }'"


if thePID > 0 then
do shell script "kill -9 " & thePID
end if

delay 5

try
tell application "HP Communications" to run
end try

tell application "Finder"
activate
end tell
[/code]

It is not pretty, I'm sure there are more efficient ways to do this, but given the amount of time I had, it was the best I could do.

In some cases the printer Queue also needs to be started again. (Pressing the Start Jobs button in the specific printer window)
(I'm looking into doing this with the applescript at some point, but ran out of time and a headache, so another day)



[ Reply to This | # ]