Automate Applescript to Write another Applescript

So here’s what I want to do:

I want to send my emoployees an application that they can doubleclick on and run that will do the following things:

  1. Take input for their username
  2. Take input for their password
  3. Generate a workflow application that will mount two network volumes with their login information
  4. Add this application to their login items, so on startup these will automount.

I am very new to applescript and automator, but here is what I have so far:


set DowUsername to ""
set DowPassword to ""

tell application "Finder"
	display dialog "Enter Your Dow Username:" default answer DowUsername buttons ("OK") default button 1
	set DowUsername to text returned of the result
end tell

tell application "Finder"
	display dialog "Enter Your Dow Password:" default answer DowPassword buttons ("OK") default button 1
	set DowPassword to text returned of the result
end tell

tell application "Finder"
	try
		mount volume "smb://" & DowUsername & ":" & DowPassword & ">@192.168.1.60/DropFolders"
		mount volume "smb://" & DowUsername & ":" & DowPassword & ">@192.168.1.60/Anystream_Output"
	end try
end tell

That works to get their login information and pass it to mount the drives, but like I said, I want to take it a step further and have this generate an application that can be added to their login items at startup.

Any suggestions?

Hi,

try this, it creates the script in the scripts folder of the current user and adds it to the login items


set DowUsername to ""
set DowPassword to ""

tell application "Finder"
	display dialog "Enter Your Dow Username:" default answer DowUsername buttons ("OK") default button 1
	set DowUsername to text returned of the result
end tell

tell application "Finder"
	display dialog "Enter Your Dow Password:" default answer DowPassword buttons ("OK") default button 1
	set DowPassword to text returned of the result
end tell

set mountFile to ((path to library folder from user domain as text) & "Scripts:mountSMB.app")
set mountPOSIX to POSIX path of mountFile
set userPass to DowUsername & ":" & DowPassword

set theText to "try
	mount volume \"smb://" & userPass & ">@192.168.1.60/DropFolders\"
	mount volume \"smb://" & userPass & ">@192.168.1.60/Anystream_Output\"
end try"

do shell script "/bin/echo " & quoted form of theText & " | /usr/bin/osacompile -o " & quoted form of mountPOSIX

tell application "System Events" to make new login item at end of login items with properties {name:"mountSMB", path:mountPOSIX}

That works great, thanks!

One thing though, since there will be usernames and passwords in this script, is there any way to save it as a run only, so it can’t be edited?

~ Aaron

just add the -x flag


.
do shell script "/bin/echo " & quoted form of theText & " | /usr/bin/osacompile -o " & quoted form of mountPOSIX & " -x"
.

Thanks!