PDA

View Full Version : AppleScript to mount Windows shares




dwright1974
May 1, 2011, 02:11 PM
Hello All

This is my first attempt at AppleScript to mount a network share from a Windows 2003 server on a Mac. When I mount the share manually, (Go > Connect to Server) it works perfectly.

When I try and do it through AppleScript it fails every time and I was wondering if someone could help me please?

Here is the script:

============
tell application "Finder"
activate

try
display dialog "Making CC4 Drives available - Press OK to continue or Cancel to stop"
mount volume "smb://cc4stdfs/rmshared%20documents"
display dialog "RM Learning Resources are available in Finder"
on error
display dialog "This Mac is unable to access RM Learning Resources"

end try
end tell
============

And here is the Event Log:

============
tell application "Finder"
activate
display dialog "Making CC4 Drives available - Press OK to continue or Cancel to stop"
--> {button returned:"OK"}
mount volume "smb://cc4stdfs/rmshared%20documents"
--> error number -10004
end tell
tell application "AppleScript Editor"
mount volume "smb://cc4stdfs/rmshared%20documents"
--> error number -36
end tell
tell application "Finder"
display dialog "This Mac is unable to access RM Learning Resources"
--> {button returned:"OK"}
end tell
Result:
{button returned:"OK"}

============
I've Googled it but can't find anything to suggest what isn't working?

Any help anyone could be would be great!

Thanks in advance

- D



subsonix
May 1, 2011, 02:46 PM
Are you sure you have the correct path? Error -10004 is:

Mac OS error -10004 (telBadHandErr): bad handle specified

cluthz
May 1, 2011, 03:06 PM
You can use a shellscript to make it easier:


mount -t smbfs //user@server/sharename share


this wil require you the make a folder named "share" in the user folder

This wil also work, put it in login items if you want to log into it when you log on


tell application "Finder"
open location "smb://user:password@computername/sharename"
end tell

dwright1974
May 1, 2011, 05:36 PM
Hi all

Thanks for all your replies.

Will give them a try tomorrow.

Thanks again

- D