ndpete
09-09-2010, 03:44 PM
First off I'm pretty new in the apple scripting area so all the advice in the world is welcome.
Basically What I'm trying to do is have a script run at logout or restart/shutdown that will cleanup a student account.
I started by trying to run an application as a login item for the user but I've found some conflicts with trying to reset the finder preferences. I've tried to quit finder and start it again but i still get an error.
Anyone have some advice on how to modify this script to work at login or how to run one similiar to this at logout or shutdown?
This is what I have so far: I run a script before making a master copy of the plists to a directory then use those to copy them back
#Clear the Desktop and Downloads folders
do shell script "rm -rf /Users/$USER/Desktop/*"
do shell script "rm -rf /Users/$USER/Downloads/*"
#Empty Trash
do shell script "rm -rf /Users/$USER/.Trash/*"
#Reset the Dock
do shell script "cp -af /Users/$USER/Library/CleanupScript/dock.plist /Users/$USER/Library/Preferences/com.apple.dock.plist"
do shell script "cp -af /Users/$USER/Library/CleanupScript/dock.db /Users/$USER/Library/Preferences/com.apple.dock.db"
tell application "Dock" to quit
#Reset Finder Preferences
tell application "Finder" to quit
do shell script "cp -af /Users/$USER/Library/CleanupScript/finder.plist /Users/student/Library/Preferences/com.apple.finder.plist"
do shell script "cp -af /Users/$USER/Library/CleanupScript/sidebar.plist /Users?$USER/Library/Preferences/com.apple.sidebarlists.plist"
tell application "Finder" to open
This was going to run at login but a modified one could be run at logout for the same results I think. In my testing everything worked except the Finder part.
Thanks for the help
-NDPETE
Basically What I'm trying to do is have a script run at logout or restart/shutdown that will cleanup a student account.
I started by trying to run an application as a login item for the user but I've found some conflicts with trying to reset the finder preferences. I've tried to quit finder and start it again but i still get an error.
Anyone have some advice on how to modify this script to work at login or how to run one similiar to this at logout or shutdown?
This is what I have so far: I run a script before making a master copy of the plists to a directory then use those to copy them back
#Clear the Desktop and Downloads folders
do shell script "rm -rf /Users/$USER/Desktop/*"
do shell script "rm -rf /Users/$USER/Downloads/*"
#Empty Trash
do shell script "rm -rf /Users/$USER/.Trash/*"
#Reset the Dock
do shell script "cp -af /Users/$USER/Library/CleanupScript/dock.plist /Users/$USER/Library/Preferences/com.apple.dock.plist"
do shell script "cp -af /Users/$USER/Library/CleanupScript/dock.db /Users/$USER/Library/Preferences/com.apple.dock.db"
tell application "Dock" to quit
#Reset Finder Preferences
tell application "Finder" to quit
do shell script "cp -af /Users/$USER/Library/CleanupScript/finder.plist /Users/student/Library/Preferences/com.apple.finder.plist"
do shell script "cp -af /Users/$USER/Library/CleanupScript/sidebar.plist /Users?$USER/Library/Preferences/com.apple.sidebarlists.plist"
tell application "Finder" to open
This was going to run at login but a modified one could be run at logout for the same results I think. In my testing everything worked except the Finder part.
Thanks for the help
-NDPETE