AppleScript to mount Windows shares

Discussion in 'Mac Programming' started by dwright1974, May 1, 2011.

  1. dwright1974, May 1, 2011
    Last edited by a moderator: May 1, 2011

    macrumors 6502

    dwright1974

    Joined:
    Aug 13, 2007
    Location:
    UK
    #1
    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:

    ============
    Code:
    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:

    ============
    Code:
    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
     
  2. macrumors 68040

    Joined:
    Feb 2, 2008
    #2
    Are you sure you have the correct path? Error -10004 is:

     
  3. cluthz, May 1, 2011
    Last edited by a moderator: May 1, 2011

    macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #3
    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

    Code:
    tell application "Finder"
    open location "smb://user:password@computername/sharename"
    end tell
    
     
  4. thread starter macrumors 6502

    dwright1974

    Joined:
    Aug 13, 2007
    Location:
    UK
    #4
    Hi all

    Thanks for all your replies.

    Will give them a try tomorrow.

    Thanks again

    - D
     

Share This Page