Print from Windows 7 to a Mac Shared Printer

I recently upgraded my wife’s laptop from Windows Vista to Windows 7 Home Premium. (The laptop manufacturer sent us a free upgrade coupon since we purchased it not too long before Windows 7 was released.) This morning she discovered that she can’t print to the Canon MP830 that is shared from the G5 Mac (running Mac OS X 10.5.8) in our living room. In Vista, I had it working via Bonjour. I’ve now learned a little too late that Bonjour doesn’t work in Windows 7. (see UPDATE) I googled for a solution, but all I was able to find was a bunch of other people complaining about the same thing: printing from Windows 7 to a printer shared from Mac OS X wasn’t working as it had been in Windows XP or Vista.

Not to worry, though. After about 30 minutes of trying various solutions and just poking around in Windows 7, I found that the solution is pretty simple. The following procedure assumes you already have Printer Sharing enabled on your Mac. Continue reading

Open a Root Finder Window in Snow Leopard or Later

This is an update to an existing post about the same topic. Yes, you can still open a root Finder window in Snow Leopard, but there is an extra step required.

First, run the following command in Terminal and then enter your password:

sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder

Next, click on an empty spot on your desktop — not in an existing Finder window. Now, type Command-N  (⌘-N) or select New Finder Window from the File menu. A new Finder window resembling the following should open:

root-window

You can see that it opens up to the root user’s home. Use this window to navigate anywhere you like and make the changes you need. Keep in mind that you can do just as much damage with this as you can in the Terminal as root.

To end your root Finder session, go back to the Terminal window and hit ^C.

Quirks to be Mindful of

  • You won’t be able to interact with any files you might have on your desktop, as those belong to your logged-in user account and root’s desktop is currently (and transparently) sitting on top of it.
  • If you take any screenshots, they will be owned by the logged-in user and you’ll need to navigate to them via your root Finder window.
  • If you attempt to open/double-click a file which requires root access to read, the corresponding application will open as the logged-in user and the file will fail to open. To get around this, you can launch the app’s /Contents/MacOS executable as root and open the file from within the app.

Open a Finder Window with Root Access

UPDATE (9/28/09): Got Snow Leopard? Please see this post for updated instructions.

— — — —

It’s occasionally handy when troubleshooting a problem in OS X to have root access in the Finder without having to log out of your current session. Sure, you can do most things in the Terminal, but the GUI can be much handier for certain tasks. This is a quick-and-dirty Terminal trick to open a Finder window with root access.

Run the following command and then enter your password:

sudo /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder

A new Finder window resembling the following should open:

root-window

You can see that it opens up to the root user’s home. Use this window to navigate anywhere you like and make the changes you need. Keep in mind that you can do just as much damage with this as you can in the Terminal as root.

To end your root Finder session, go back to the Terminal window and hit ^C.

Quirks to be Mindful Of

  • You won’t be able to interact with any files you might have on your desktop, as those belong to your logged-in user account and root’s desktop is currently (and transparently) sitting on top of it.
  • If you take any screenshots, they will be owned by the logged-in user and you’ll need to navigate to them via your root Finder window.
  • If you attempt to open/double-click a file which requires root access to read, the corresponding application will open as the logged-in user and the file will fail to open. To get around this, you can launch the app’s /Contents/MacOS executable as root and open the file from within the app.

Test for 64-bit Capability

UPDATE (10/8/08): The following one-liner will work on ppc or intel boxes and will return 1 if the computer is 64-bit capable or 0 if it is not. UPDATE 2 (12/11/08):  Reader Ted suggested suppressing stderr for cleaner output. I amended the code below to include his suggestion.

sysctl hw.optional 2> /dev/null | awk -F': ' '/64/ {print $2}'

The arch tool is an easy way to test whether a Mac’s processor is intel or ppc, but it does not draw a distinction between the different types of intel processors. It will return i386 whether it’s a Core Duo, Core 2 Duo, or Xeon. We can use the fact that the Core Duo is only intel processor found in Macs incapable of running 64-bit code to write a script that extend arch to test for 64-bit capability.

    #!/bin/bash

    proc=$(/usr/sbin/system_profiler SPHardwareDataType | \
    /usr/bin/awk -F': ' '/Processor Name:/ {print $2}')

    if [ "$(/usr/bin/arch)" == "i386" ]; then
        if [ "$proc" != "Intel Core Duo" ]; then
            /bin/echo $(/usr/bin/arch)-64
        else
            /bin/echo $(/usr/bin/arch)-32
        fi
    else
        /bin/echo $(/usr/bin/arch)
    fi

This script will return i386-32 for intel processors limited to 32 bits, i386-64 for 64-bit capable intel processors, and ppc for non-intel processors.

I’ve called this script archbits and made it downloadable here.

networksetup – Change Network Settings from the Command Line

UPDATE (8/12/08): I simplified the awk portion of the command.

Mac OS X comes with a very convenient tool called networksetup that makes it relatively easy to view or change network settings from the command line. In Leopard, the command is readily available at /usr/sbin/networksetup. Since /usr/sbin exists in the default path, you can access the command directly. In Tiger, Panther, and Jaguar, the command is not anywhere in the default path, but lives buried within the bundled ARD Agent at /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup. (If you’re not using Leopard, be sure to include the full path to the executable in all of your commands.) Apple’s man page for networksetup covers all the available options but it’s short on real examples of its use.

Continue reading