Network Mount script and "NSCannotCreateScriptCommandEr


I am trying to create a script that will map a home drive for our students and staff when they log in to our labs.

The script seems to work fine and the home directory mounts correctly however I get the following error at the end of the script:

This the first segment of the script below. What is wrong with it that causes this error???

[b]set currentUser to (do shell script “echo $USER|awk -F@ {‘print $1’}”)
if exists (mount volume “cifs://domainname/dfshare/nameofshare/” & currentUser & “/My Documents”) then
tell application “Finder”
mount volume “cifs://domainname/dfshare/nameofshare/” & currentUser & “/My Documents”
end tell
end if

It seems just to be the “if exists…” line that causes the problem.

Can someone help.

I know I am close.

Thanks Greg Turnbull

You can use simply:

set currentUser to (do shell script "echo $USER|awk -F@ {'print $1'}") 
     mount volume "cifs://domainname/dfshare/nameofshare/" & currentUser & "/My Documents"
end try

It will mount the volume, otherwise will fail silently.

The following code allows me to check if a local volume is mounted, and if it is not it mounts automatically. Hope this helps.

set ThisVolume to "afp://login:password@Red-Checkout.local" --the volume to be mounted
set ThisFolder to "Crimson:Users:purp:Desktop:ToBeFaxedFolder" --the folder to be accessed on the mounted drive
--check to see if the volume is already mounted, if not then give command to mount the volume
		if (list disks) does not contain "Crimson" then mount volume ThisVolume
		tell application "Finder"
			open ThisFolder
			move target_file to ThisFolder  --copies a file to the mounted folder
		end tell