This topic describes how to create a mount script and a scheduled task to enable an automatic mount at startup for an SMB file system.

Prerequisites

  1. A file system is created. For more information, see Create a file system.
  2. A mount target is created. For more information, see Add a mount target.
  3. The following Windows services are started:
    • Workstation
      1. Choose All Programs > Accessories > Run, or press Win+R and enter services.msc to open the Services console.
      2. Find the Workstation service and ensure that the service is Running and the startup type is Automatic.

        The default state for the Workstation service is Running.

        Workstation
    • TCP/IP NetBIOS Helper

      Perform the following steps to start the TCP/IP NetBIOS Helper service:

      1. Open Network and Sharing Center and click the active network connection.
      2. Click Properties to open the Local Area Network Properties dialog box. Double-click Internet Protocol Version 4 (TCP/IPv4) to open the Internet Protocol Version 4 (TCP/IPv4) Properties dialog box, and then click Advanced.
      3. In the Advanced TCP/IP Settings dialog box, choose WINS > Enable NetBIOS over TCP/IP.Enable NetBIOS over TCP/IP
      4. Choose All Programs > Accessories > Run, or press Win+R and enter services.msc to open the Services console.
      5. Find the TCP/IP NetBIOS Helper service and ensure that the service is Running and the startup type is Automatic.

        The default state for the TCP/IP NetBIOS Helper service is Running.

        TCP/IP NetBIOS Helper

Procedure

  1. Log on to the ECS console.
  2. Create a script file named nas_auto.bat and add the following command to the file.
    net use D: \\file-system-id.region.nas.aliyuncs.com\myshare 

    The format of the command used to mount the file system is net use <the drive of the mount point> \\<the domain name of the mount target>\myshare.

    • The drive of the mount point: The target drive on which you need to mount a file system. You can select the target drive based on your business requirements.
    • The domain name of the mount target: When you create a mount target for a file system, the domain name of the mount target is automatically generated. You can replace the domain name based on your business requirements. For more information, see Manage mount targets.
    • myshare: The name of an SMB share. You cannot change the name.
    Note

    The name of the target mount drive must be unique on the target ECS instance.

    For more information about how to troubleshoot the errors returned by the mount command, see Troubleshoot and fix mount issues.

  3. Create a scheduled task.
    1. Open the Control Panel and choose Administrative Tools > Task Scheduler.
    2. In the Task Scheduler window, choose Action > Create Task.
      Create a task
    3. Select the General tab, enter the Name of the task, and select Run whether user is logged on or not and Run with highest privileges.
      General settings
    4. Select the Triggers tab, click New, select At log on in the Begin the task field, select Enabled in the Advanced settings section, and click OK.
      Triggers settings
    5. Select the Actions tab, click New, select Start a program in the Action field, select the nas_auto.bat file in the Program/script field, and click OK.
      Start a program
    6. Select the Conditions tab, and select Start only if the following network connection is available. Select Any connection under Start only if the following network connection is available.
      Conditions settings
    7. Select the Settings tab, select If the running task does not end when requested, force it to stop, and select Do not start a new instance under If the task is already running, then the following rule applies.
      Settings
    8. Click OK.
    9. Restart the ECS instance to verify whether the scheduled task is created.

      The following figure shows an example of a successful creation.

      Creation result
  4. Open the command prompt and run the net use command to verify the mount result.

    The following figure shows an example of a successful mount.

    If the mount is unsuccessful, see Troubleshoot and fix mount issues.

  5. After mounting an Apsara File Storage NAS file system, you can use the ECS instance to read data from and write data to the file system.