I am trying to create an Apple Script so that the com.apple.dock.plist file is overwritten by one of my choice, then the dock restarts. every-time a user logs in. This way I can keep the docks looking the same computer to computer.
This is what I am trying, but nothing is happening
tell application “Finder”
duplicate file “source file here?” to folder “What would I put here so the current users com.apple.dock.plist is overwritten by the one of my choice”
replacing
true
end tell
Should I also be employing something like this?
set CurrentUser to do shell script “whoami”
set ThePath to “/Users/” & CurrentUser & “/Library/Preferences/”
Basically I need my com.apple.dock.plist to be overwritten to users/currentuser/library/preferences -so first I need the current user to be found
Sorry this is a very beginner-ish question. I am new to Apple script.
set userPrefFolder to path to preferences -- the preferences folder of the current user
set myDockPrefs to (choose file without invisibles)
quit application "Dock"
tell application "Finder" to duplicate myDockPrefs to userPrefFolder replacing yes
launch application "Dock"
Will using the “userpreffolder” section copy the file to the current users preferences regardless of what user just logged in? I want this script to be universal as it will be deployed in a lab situation
The path to preferences portion, would I put somethings like /users/ … or?
I don’t however want to write a script for each user. I need it to be universal as it will run at startup, or am I missing something in your explanation?
What part of this script should I be actually editing?
I think the “choose file” portion might be a problem, since he’s wanting this to run mostly “hands off” for the user. However, he probably has a known place for the dock prefs he wants to install, that’s simple enough to edit and change.
itsallinurhead,
You’re making it harder than it has to be. Trust Stefan, he’s a good scripter and knows what he is talking about.
Sorry, my questions are quite stupid. Yes, I do have a set location for the dock prefs. I was going to put them in a place available to all users, but make it not editable.
Kevin, will what you said be a problem, or will this indeed run hands off?
I recommend to save the script as application bundle,
then open its package folder with the contextual menu > Show package contents
and put your reference file com.apple.dock.plist into the folder Contents:Resources:
This modified script copies the file from the mentioned place into the preferences folder of the current user
set userPrefFolder to path to preferences -- the preferences folder of the current user
try
set myDockPrefs to ((path to me as Unicode text) & "Contents:Resources:com.apple.dock.plist") as alias
quit application "Dock"
tell application "Finder" to duplicate myDockPrefs to userPrefFolder replacing yes
launch application "Dock"
on error
display dialog "Preference file couldn't be found" buttons {"Cancel"} default button 1
end try
Could I just add this to the end of that script? I am using a program that edits the loginwindow file so all these scripts run when the user first logs in, but it only allows me to run one script.
tell application “Finder”
try
mount volume “smb://ls1-mach/USERS$/”
end try
end tell
More than once in the shell script I create? I ask so I can just launch the different scripts I have created rather then figuring out how to combine them and having to ask further questions.