Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Operating System
Applescript Q: Can you use applescipt to give mounted network volumes unique names
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="dcrutch" data-source="post: 1257338" data-attributes="member: 205711"><p>Hi all, </p><p></p><p>Through some digging (google) and trial and error, I have pieced together the following script that does what I want it to do.</p><p>1) It asks the user for their username and password</p><p>2) It authenticates that info with our domain</p><p>3) It maps 4 windows network shares (DFS shares) for the user</p><p></p><p>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.</p><p></p><p>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).</p><p></p><p>Assumptions:</p><p>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.</p><p>I don’t want to join the macs to the domain.</p><p>I want to avoid alias’ if possible.</p><p>I want to do this in a single script.</p><p></p><p>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.</p><p></p><p>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?</p><p></p><p>to getusername()</p><p> </p><p> display dialog "Enter your username:" default answer ""</p><p> </p><p> set username to text returned of result</p><p> </p><p> return {username}</p><p> </p><p>end getusername</p><p></p><p>to getuserpwd()</p><p> </p><p> display dialog "Enter your password:" default answer "" with hidden answer</p><p> </p><p> set userpwd to text returned of result</p><p> </p><p> return {userpwd}</p><p> </p><p>end getuserpwd</p><p></p><p>set userID to getusername()</p><p></p><p>set userpass to getuserpwd()</p><p></p><p>set Domain to "mydomain"</p><p></p><p># Map their Work drive</p><p></p><p>tell application "Finder"</p><p> </p><p> try</p><p> mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/work/" & userID</p><p> end try</p><p> </p><p>end tell</p><p></p><p># Map their Department drive</p><p></p><p>tell application "Finder"</p><p> </p><p> try</p><p> mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/department/"</p><p> end try</p><p> </p><p>end tell</p><p></p><p># Map their Posting drive</p><p></p><p>tell application "Finder"</p><p> </p><p> try</p><p> mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/posting/" & userID</p><p> end try</p><p> </p><p>end tell</p><p></p><p># Map their Receiving drive</p><p></p><p>tell application "Finder"</p><p> </p><p> try</p><p> mount volume "smb://" & Domain & ";" & userID & ":" & userpass & "@server/receiving/" & userID</p><p> end try</p><p> </p><p>end tell</p></blockquote><p></p>
[QUOTE="dcrutch, post: 1257338, member: 205711"] 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 [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Operating System
Applescript Q: Can you use applescipt to give mounted network volumes unique names
Top