Spacer http://macenterprise.org MacResource.org - Mac OS X enterprise deployment project Spacer
Site Map Contact Us Site Map About Us Top Background
 
Search
 
 
Updating Office 2004 Dock icons E-mail
Written by Greg Neagle   
Tuesday, 09 November 2004
One solution for updating icons in user's Docks when you upgrade software. In one-to-one deployments, you may not have direct control of a user's Dock - especially if you do not use Macintosh Manager becuase you are using a non-Apple directory. When you update applications on a user's machine, this sometimes breaks Dock items. We faced this when updating machines from Office v.X to Office 2004. I wrote a script that ran at login that changed any existing Office v.X Dock icons into their corresponding Office 2004 icons:
#!/usr/bin/perl
# This script edits com.apple.dock.plist
# to remove Office X entries and replace them with
# Office 2004 entries.
#
#
# by Greg Neagle Jul 2004
$homedir = $ENV{'HOME'};
# is Office 2004 installed?
if (-d "/Applications/Microsoft Office 2004") {
# has this script done its thing?
if (!(-e "$homedir/Library/Preferences/com.apple.dock.plist.officex")) {
open DOCKPREFS, "$homedir/Library/Preferences/com.apple.dock.plist"
or die ("Cannot open $homedir/Library/Preferences/com.apple.dock.plist");
open DOCKOUTPUT, ">$homedir/Library/Preferences/com.apple.dock.plist.new"
or die ("Cannot open $homedir/Library/Preferences/com.apple.dock.plist.new for output");
until (eof DOCKPREFS) {
$text = readline(DOCKPREFS);
print DOCKOUTPUT "$text";
if ($text =~ "file-data") {
$dictBlock = "";
$officeAppFound = 0;
while(!($text =~ "")) {
$text = readline(DOCKPREFS);
if ($text =~ "/Applications/Microsoft Office X/") {
# replace the path
$text =~ s/Microsoft Office X/Microsoft Office 2004/;
$officeAppFound = 1;
}
$dictBlock = $dictBlock . $text;
}
if ($officeAppFound) {
# get rid of the _CFURLAliasData block
$dictBlock =~ s|_CFURLAliasData.*||s
}
print DOCKOUTPUT "$dictBlock";
}
}
close (DOCKOUTPUT);
close (DOCKPREFS);
#rename our files
`mv $homedir/Library/Preferences/com.apple.dock.plist $homedir/Library/Preferences/com.apple.dock.plist.officex` ;
`mv $homedir/Library/Preferences/com.apple.dock.plist.new $homedir/Library/Preferences/com.apple.dock.plist` ;
# restart the Dock
`killall Dock`;
}
}
#END

The basic concepts here could be used to update other icons. The key points are that the path to the item is modified, and that the "CFURLAliasData" is removed. This needs to be removed because it is an alias that points to the old file item. The first time the user clicks on the icon after the update, this data is regenerated based on the pathname.
Add as favourites (170) | Quote this article on your site | E-mail

Be first to comment this article
RSS comments

Only registered users can write comments.
Please login or register.

Powered by AkoComment Tweaked Special Edition v.1.4.4

Last Updated ( Thursday, 03 January 2008 )
 
Next >