10.5: Remove Shut Down from the Apple menu

Nov 16, '09 07:30:00AM

Contributed by: donpardo

Leopard only hintWe have some users who, through habit or sloppy clicking, always shutdown their machine when they leave. This means that we can't perform maintenance without walking to the machine. If you need to prevent users from shutting down machines so you can do maintenance, this will help by removing the Shut Down item from the Apple Menu.

The following patch removes the Shut Down menu item for everyone on the system, admin and non-admin users alike. The patch doesn't delete the entire object, it just replaces the content of the object with a separator. Deleting the entire object causes Bad Things To Happen. You can probably use this method to remove other items in the Apple Menu, but I haven't tested that.

Warning: Altering anything under /System/Library is always risky. Don't deploy this without testing it thoroughly in your environment. I don't know for sure what will happen when updates are applied to the box, though I haven't seen any problems.

You will need to be an admin user or root to apply this patch:

----- Start here -----
--- objects.xib.orig    2009-11-02 12:36:04.000000000 -0500
+++ objects.xib 2009-11-02 13:48:07.000000000 -0500
@@ -180,10 +180,7 @@
     </object>
     <reference idRef="283"/>
     <object class="IBCarbonMenuItem" id="238">
-      <string name="title">Shut Downâ¦</string>
-      <boolean name="dynamic">TRUE</boolean>
-      <boolean name="notPreviousAlternate">TRUE</boolean>
-      <ostype name="command">rsdn</ostype>
+      <boolean name="separator">TRUE</boolean>
     </object>
     <object class="IBCarbonMenuItem" id="241">
       <string name="title">Recent Items</string>
@@ -343,10 +340,7 @@
         <reference idRef="284"/>
         <reference idRef="238"/>
         <object class="IBCarbonMenuItem" id="285">
-          <string name="title">Shut Down</string>
-          <boolean name="dynamic">TRUE</boolean>
-          <int name="keyEquivalentModifier">1572864</int>
-          <ostype name="command">shut</ostype>
+          <boolean name="separator">TRUE</boolean>
         </object>
         <reference idRef="239"/>
         <reference idRef="240"/>
------- End here ------
Save it as menu.diff, and apply it as follows. First, change to the directory where the Standard Menu xib file lives:
cd /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/English.lproj/StandardMenus.nib
Then apply the patch:

patch --fuzz=0 -B ~/ -b objects.xib /path/to/the/saved/menu.diff

This will only apply the patch if it matches exactly (--fuzz=0) and will save a copy of the objects.xib file into your home directory (-B ~/ -b). If there are any problems, you can copy the file back to the correct location. Log out then log back in and the menu item should be gone.

[robg adds: I haven't tested this one, and if you're going to do so, please be careful - modifying system files can lead to bad things, as the warning notes!]

Comments (23)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20091104040449752