Have you ever wanted to map network drives on login?
I have. My PC has much more HDD storage available than my Mini (750+GB compared to 80GB), so I use it as a Music/Movie/File server on my network (PC, laptop, and Mini). Unfortunately, I'm also lazy, and having to manually add my shares each time I logged in really was an annoyance. I like having the icons on the desktop readily available for me, one for Music, one for Movies, and one for Images. To make it even more critical to map things on login, I run iTunes almost constantly, and my Music library (40+GB) is on my PC. So, for the purposes of a basic tutorial, I'm going to teach you how to write a basic Automator script to map a network share from a Windows machine, including the Windows steps so you don't foul it up. Without any further ado, here we go.
Step 1: Prepare your Windows machine to share.
Navigate to the folder that you want to share, right click on that folder, select Properties. Click on the Sharing tab near the top. You will either have something similar to the image below, or you will have a warning asking you about setting up a network. Choose "enable file sharing."
From this pane you can also choose to allow network users to change my files. Depending on what you're sharing, you may or may not want to do this.
Step 2: Test your Windows share.
Now that you've shared your directory on your Windows machine, you want to test it before you automate it. Any problems should show up here, and it will certainly alleviate some headaches down the road.
Open up Macintosh HD from the desktop. Click on "Network" in the top left area of the Finder window. Next, select the folder that has the same name as your workgroup. Next select the computer that has the folder you want access to. At this point your screen should look something like this:
Next you will want to click the "Connect..." button seen in the previous image. This will bring up one of two boxes. If you haven't connected to a share before on that computer and clicked the Remember User Name/Password box, it will ask you to authenticate. This shouldn't be a problem. From my experience either your Windows machine username and password or "Guest" with no password works. Guest won't work if you've disabled the guest account in Windows. The other box you should see should look like this:
The drop down menu lists the shares available on the machine you are trying to connect to. Choose which one you want, and write it down, you'll need this later.
Step 3: Writing your Automator script.
At this juncture you should already have an icon on your desktop showing the share you just connected to. In this step we are going to create a script in Automator to do all of this work for you. Open Automator and select Finder from the left pane.
Next, drag the "Get Specified Servers" from the second pane into the work area. Expand the "Get Specified Servers" that you put in the work area. Click on the + at the bottom left to add a server. You should now have a pane up that looks something like this:
Near the top of this pane there should be a drop-down menu that says At:. Check that drop-down menu to see if the share you connected earlier is in there under "Recent Severs" - if it is, select it. If not, browse through as you did earlier to find your computer with the shares on it. Make sure that down at the bottom you have selected to show File Servers, as the default is Web Servers. Once you have found the computer you want to connect to, the address should show up in the Address bar. At this point you need to pull out that share name that I had you write down. In the example the computer address is smb://NUKEMM;BRANDON1 - the share name is Music, therefore the share address is smb://NUKEMM;BRANDON1/Music. The /Music is the share name. Now that you have selected your share, click Connect.
Step 4: Connecting the Share.
This step is really easy. Select "Connect to Servers" from the "Actions" pane and drag to the work area. The default selection under "URLs" is "Use results from the Previous Action." If that isn't checked, select it, and move on.
Step 5: Mounting the Share
This step is very easy, just like the last step. Select "Mount Disk Image" from the "Actions" pane and drag to the work area. Again, make sure "Use results from the previous action." is selected. Once that is accomplished, click the Run button (Play button) near the top-right. This is going to run your script and see if there are any problems. Any steps with problems will have a red circle next to them, all others will have a green circle. If you have no problems, save your workflow as an application, and put it somewhere that you can find it, you'll need it for the next step. If it does have problems, double check all of your steps and try again. Your finished project should look something like the following image:
Step 6: Automating Automator
In this step we will automate your script by adding it to the Login Items options under your user preferences. For this, open your System Preferences, and select Accounts. Select Login Items From the middle-right section of the pane, and click the + button down at the bottom left to add an item. Find your app that you created in Automator, and select it, as seen below.
Now that you've added our app to the list of Login Items, it's time to test this out. Assuming your app worked when run from Automator, all you need to do to test your app is log out and log back in. Once you've logged in you should have an icon on your desktop connecting you to the share you created.
Hopefully this works for someone besides myself. Any comments or suggestions can be sent to me via PM, and I can make changes as necessary. Good luck!