Applescript Q: Can you use applescipt to give mounted network volumes unique names

Joined
Jun 23, 2011
Messages
2
Reaction score
0
Points
1
Hi all,

Through some digging (google) and trial and error, I have pieced together the following script that does what I want it to do.
1) It asks the user for their username and password
2) It authenticates that info with our domain
3) It maps 4 windows network shares (DFS shares) for the user

So my only problem now is that when the 4 drives map, 3 of them map with the same name because three of the paths that are mapped end in folders named after the username. Because of DFS and user rights, I can’t map them a folder level higher, the path must end with their username folder.

Thus I end up with 1 department drive and 3 username drive icons on the desktop, whereas I want to end up with 4 uniquely named drive icons on the desktop, to reduce end user confusion (work, department, posting, receiving).

Assumptions:
I would like this script to work for remote users who aren’t joined to AD, so they would VPN connect to us, then run the script to map the drives. Again, this works now, just have the naming issue.
I don’t want to join the macs to the domain.
I want to avoid alias’ if possible.
I want to do this in a single script.

So I’d like to find a way to modify this existing script to rename mounted volumes to names that I choose. Right now the network icon on the desktop is named for the last folder in the path.

Once you “mount volume” is there a way within applescript to then rename that mounted volume so the 4 icons that show up on the user’s desktop each have a unique name?

to getusername()

display dialog "Enter your username:" default answer ""

set username to text returned of result

return {username}

end getusername

to getuserpwd()

display dialog "Enter your password:" default answer "" with hidden answer

set userpwd to text returned of result

return {userpwd}

end getuserpwd

set userID to getusername()

set userpass to getuserpwd()

set Domain to "mydomain"

# Map their Work drive

tell application "Finder"

try
mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/work/" & userID
end try

end tell

# Map their Department drive

tell application "Finder"

try
mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/department/"
end try

end tell

# Map their Posting drive

tell application "Finder"

try
mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/posting/" & userID
end try

end tell

# Map their Receiving drive

tell application "Finder"

try
mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/receiving/" & userID
end try

end tell
 
OP
D
Joined
Jun 23, 2011
Messages
2
Reaction score
0
Points
1
Update: Looks like Lion may support DFS mappings (hoping it releases this month), so I'm going to wait to see how that works with WGM (workgroup manager) and I'll join them to AD if needed.

While my script is still useful for mapping drives, it's not ideal for mass enterprise deployment and I'd still have my original problem of several mapped volumes with the same name.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top