How to Use Automator and Applescript to Automate Connecting to a Specific SMB Drive

How to Use Automator and Applescript to Automate Connecting to a Specific SMB Drive
How to Use Automator and Applescript to Automate Connecting to a Specific SMB Drive

When I switched to OS 10.9 Mavericks my shortcuts to the Windows Server 2003 shared network domain drives did not function properly.  I was able to view files but couldn’t change file names or save to the disk.  I learned that Apple changed the SMB driver they used and this really messed up my workflow.  I had saved some aliases to network drives but, although they would connect when I would click on them, I could not use the drives like necessary.  I wrote a posting on how connecting to these new drives as a CIFS (Common Internet File System) drive instead of a SMB (Server Message Block) drive:

How to Copy Files to a Windows Network Drive Using Mavericks OS 10.9

Since then I’ve been using the Finder to manually connect to these drives but I’ve wanted to automate it of course.

How to Use Automator and Applescript to Automate Connecting to a Specific SMB Drive

Here’s how you can use Apple’s Automator program to connect to a specific drive on your SMB share and connect via CIFS so you don’t loose any functionality because of Apple’s changes in Mavericks:

Step 1:  Launch Automator.

You can find it in the Applications folder of your Mac’s HD.

Apple Automator

Step 2:  Choose “Application” from the document type menu that pops up when you launch Automator and click the “Choose” button (or just double-click on the Application icon).

This will create an executable file you can run to mount the drives and you can place it in your dock.

Pick “Application” for the type of document

Step 3:  Type “applescript” into the actions search box at the top left side of the window.

Searching for “Run AppleScript” action

Step 4: Drag and drop the “Run AppleScript” action to the right window that says “Drag actions or files here to build your workflow.”

This is what you’ll get:

Drag-and-drop “Run AppleScript” to the workflow window

Step 5: Enter the AppleScript code.

Enter the following code and replace “username”, “password”, “server-name”, and “drive” with your information:

on run {input, parameters}
tell application “Finder” to open location “cifs://username:password@server-name/drive”
return input
end run

 

This is what the code will look like and what Automator will look like when you are ready to save your application (except personalize the server, drive, username, and password details):
AppleScript in Automator

Step 6: Save the Application to your Hard Drive.

From the File menu choose “Save.”
Save the Workflow Application

Step 7: Place the Application in your dock for easy access.

Now you can connect to a particular share with the click of an icon.
Automator Application in Dock — Connect to Shared Drives with a click!

My other Apple Automator blog posts:

Amazon Associate Disclosure: As an Amazon Associate I earn from qualifying purchases. This means if you click on an affiliate link and purchase the item, I will receive an affiliate commission. The price of the item is the same whether it is an affiliate link or not. Regardless, I only recommend products or services I believe will add value to Share Your Repair readers. By using the affiliate links, you are helping support Share Your Repair, and I genuinely appreciate your support.

Tags from the story
, , , , , ,
Written By
More from John Mueller
How to Create a Mac Application to Merge Pdf’s in Automator
Often we need to merge multiple pdfs into one document and it’s...
Read More

Leave a Reply

Your email address will not be published. Required fields are marked *