AppleScript to Add Applications to Doc

Hi All,

I have tried looking into this with no luck. i am trying to create an applescript that puts certain applications in the doc, like when you drag and drop into the doc.

Where i work we regulary install OSX etc, and am trying to create a large install script to automate most of the small things that need to be done, like cleanup files, setting backgrounds , setting defualt background when the Mac updates. But this one seems to allude me.

Any Help would be greatly appreciated

An example of what Apps i would need t move into dock would be:

Calc
Grab
Quicktime
Mail
Firefox

That’s what I’ve been up to, lately :slight_smile:

So:

-- Inspiration from Luther Fuller
--	http://lists.apple.com/archives/applescript-users/2009/Oct/msg00124.html
--	http://lists.apple.com/archives/applescript-users/2009/Jul/msg00286.html
--
-- the lists of apps we want to install
-- it's actually tables with relative paths & localised names
property userApps : {{"Safari", "Safari"}, {"iCal", "iCal"}, {"iTunes", "iTunes"}, {"System Preferences", "Systeemvoorkeuren"}} -- for template user
property adminApps : {{"Safari", "Safari"}, {"System Preferences", "Systeemvoorkeuren"}, {"/Utilities/Disk Utility", "Schijfhulprogramma"}, {"/Utilities/Terminal", "Terminal"}} -- for administrator
-- custom settings; adding them when already present does not cause errors
property customDockSettings : {showhidden:true, |no-glass|:true, |trash-full|:true, |minimize-to-application|:false, autohide:false, largesize:47.703704833984, magnification:true, orientation:"left", tilesize:32.0, mineffect:"scale"}
--
-- whose account is this?
--
set thisOwner to (do shell script "logname")
--
-- get his app list
--
if thisOwner is "config" then -- the administrator
	set appList to adminApps
else if thisOwner is "anderen" then -- the template user
	set appList to userApps
else
	beep
	display dialog "Can't run in this account" buttons "Quit" default button 1
	tell me to quit
end if
--
-- read the plist
-- remove default apps
-- remove folders
--
set prefsFile to (((path to preferences from user domain) as text) & "com.apple.dock.plist") as alias
tell application "System Events"
	set dockPath to (prefsFile as text)
	set dockRec to (value of property list file dockPath)
	set |persistent-apps| of dockRec to {} -- remove apps
	set |persistent-others| of dockRec to {} -- remove folders
	set dockRec to dockRec & customDockSettings -- add custom settings
end tell
--
-- add my own apps
--
repeat with anApp in appList
	addDock(anApp, dockRec)
end repeat
--
-- finish
--
tell application "System Events" to set (value of property list file dockPath) to dockRec -- save the data
tell application "Dock" to quit -- restart Dock

---------------------------------------------------------
on addDock(anApp, dockRec)
	-- 1 construct the |file-data| record
	set appUrl to "/Applications/" & item 1 of anApp & ".app/"
	set newAppData to {|_CFURLString|:appUrl, |_CFURLStringType|:0}
	
	--2 construct the |tile-data| record
	set newTileData to {|dock-extra|:false, |file-data|:newAppData, |file-label|:item 2 of anApp, |file-type|:2, showas:3}
	
	-- 3 construct the newMenuAppItem record
	set newMenuAppItem to {|tile-data|:newTileData, |tile-type|:"file-tile"}
	
	-- 4 add to prefsFile record
	tell application "System Events" to set |persistent-apps| of dockRec to ((|persistent-apps| of dockRec) & {newMenuAppItem}) --add the app
	
end addDock

Can do?

And maybe you can help me with

Did you mean the desktop picture? I tried, but no luck.

Cheers alastor933, will play with this code later on today.

The background i was referring to was the background that is shown when apple applies its updates.




display dialog "Apple Default Background Remover 1.0, Please Place Your Image on Your Desktop and Call It New.jpg" buttons {"Done", "Cancel"} default button 2 with title ("Apple Default Background Remover") 

if the button returned of the result is "Done" then
	
	tell application "Finder"
		set theFile to (desktop as text) & "New.jpg" as alias
		set name of theFile to "DefaultDesktop.jpg"
	end tell
	
	do shell script "RM  /System/Library/CoreServices/DefaultDesktop.jpg" with administrator privileges
	
	do shell script "cp -r /$HOME/Desktop/DefaultDesktop.jpg /System/Library/CoreServices/" with administrator privileges
	
	do shell script "RM  /$HOME/Desktop/DefaultDesktop.jpg"
	
	display dialog "Default Image Replaced" buttons {"Ok"} with title ("Apple Default Background Remover Finished") 
	
else
	
end if

What this does is allow me to remove the aurora default and put the company, do not turn off logo in the background.

This my Help:

http://still-scripts.com/applescript/change-your-desktop-background-with-applescript/