Adding Applications folder to dock via AppleScript?

I wanted to see if you guys might know of a way to add the applications folder to the dock in folder display view via AppleScript/Terminal? I am trying to create one script that does a bunch of simple little things like this with the click of a button. The reason why is because I work for a computer company that does these simple little things on every computer that we touch. I tried to research it and the best resource that I found was a script that does a shell script to add a recent applications folder to the dock. I’ll post that below to help jump-start your minds. I can only assume that the command in terminal would be similar to this one. I’ve tried a million times to figure it out but when i do the kill command in terminal, the dock never relaunches. Therefore I have to go into LIbrary/Preferences and delete the dock .plist file in order for it show again. I know that even when you run this “add recent applications” script, it adds the stack just to the left of the trash bin in the dock. If at all possible I would like it to be as close to the divider (white dotted line in dock) as possible. Maybe you guys might could help me out with this? And not to throw another kink in the chain but, The only reason why I cant just replace the com.apple.dock.plist file with one is like the way I want it is because it would override the current dock .plist file. What my department does is data transfers and software installs. So say for instance we get an order to install MS office for a customer, well I want to be able to install it, run this script with all this stuff that we do to every computer in it and then shut down the computer. Therefore we would have to go through and add all the office suite applications back in the dock. Any ideas or thoughts are appreciated. Thanks so much!

set docSideScript to “defaults write com.apple.dock persistent-others -array-add ‘{ "tile-data" = {"list-type" = 1; }; "tile-type" = "Recents-tile"; }’;killall Dock”
do shell script docSideScript

I showed you how to write to a plist file in your other post here, so this would be the same. You figure out what the plist file should look like, then use the commands like I showed before to make the plist file look that way. The dock’s plist file is com.apple.dock.plist.

Then you quit and relaunch the dock to make the new settings visible like this…

tell application "Dock" to quit

Im really sorry. Im super new to applescript and cant really tell exactly what to insert or replace from the dock.plist file into that other script you made to make it add the applications folder to the dock. It was a little over my head… but im so thankful for it because it works! I wondered if you could help me again with this one. Again, real sorry.