Replace and then lock file, over the network

OK, so here’s the thing. I’m a lab manager with students who use remote network user accounts on lab machines. Microsoft Word for OS X has known crashing issues when being run from remote network user accounts. The client machines run OS 10.4.8 and the Server is OS X Server 10.4.8. The research I’ve done indicates the best way to solve this MS Word problem is to replace the “Office Registration Cache X” file in the users prefs (the user directory is on the server) with a blank doc of the same name, then lock the file so when MS Word attempts to recreate this problematic file, it is unable to. It works. Now I need a script for students to run if they want to fix the problem with Word. I will store it and the blank replacement file (unlocked) on our “Help_Files” shared network volume that appears on every desktop. It must be unlocked at the start of the script in order for it to be moved and replace the bad Office Registration Cache X file. Heres what I have:

tell application “Finder”
do shell script “rm -f ~/Library/Preferences/Microsoft/‘Office
Registration Cache X’”
do shell script “cp /Volumes/Help_Files/‘Office Registration
Cache X’ ~/Library/Preferences/Microsoft/”
end try

set myHome to (do shell script "whoami")
set locked of file "Office Registration Cache X" of folder "Microsoft"

of folder “Preferences” of folder “Library” of folder myHome of folder
“hmdr” of folder “UserData” of folder “Volumes” of folder
“MyServer” of folder “Network” of folder “private”
of startup disk to true
end tell

“UserData” is a partition on the server which houses the network user folders.

The first half of this script works fine. The file is replaced. It is the locking of the new file that seems to be a problem. I get an Applescript error message that says “Cant set locked of blah blah blah” My syntax I believe is OK, I tried setting files on local drives to “locked” and it worked OK. Its either something about attempting to do this over a network that doesnt work, or its something in the path that I have wrong. When I drag the file into into the script editor, it reveals the path I entered in the script.

The shell scripts seem to be a much simpler deal, they recognize the “~/” and place the file where needed. In Applescript, the path to the file becomes trickier. Is there a shell script for locking a file? That would solve the whole problem…or can anyone help me figure out why this isnt working?

Many thanks in advance for the help,


Hi Rowie

Not sure if this helps much, but if you highlight a file on a volume across the network and get info
the locked checkbox is greyed out whereas if you copy it to your desktop it’s not.
You may need to think about using the “chown or chmod” shell commands to sort this problem out then the unlock part of your script might work.
Not sure just a shot in the dark!


Hi Pidge,

Thanks for the response. I don’t think that’s the issue here. If I select the file manually and Get Info, the locked checkbox is available, I can check it, and the goal is accomplished. The problem seems to be in the scripting of the lock action. I also made sure to change the permissions on the blank doc to read and write for everyone so it could be freely manipulated until the point where it becomes locked.

Hi rowie

Not to geared up on the unix stuff but i think this maybe what you need to lock a folder:

chflags uchg /Users/name/Desktop/folder/

Hope this helps.
open the man pages for “chflags”

That did it :smiley: Thanks a million pidge, I really appreciate the help! I searched all over the internet for unix commands to lock files, nothing worked and it was all so complex. I never even saw a hint of the command you just told me about. Maybe I wasnt searching for the right thing…in any event, thanks again, thats a great command to know about.