Announcement

Collapse
No announcement yet.

net use: cannot delete mapped drive

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • net use: cannot delete mapped drive

    I need to create a batch file that will map drive, than xcopy data, that disconnect the mapped drive.

    this what I did:

    net use S: \\KY\Company
    xcopy S:\ "f:\Public - Users - CIE\Mon - Lun\CSF" /d/e/v/y
    net use S: \\Kyard-dc\Company /d

    This what I get:
    F:\dc>net use S: \\Kyard-dc\Company /d
    A command was used with conflicting switches.

    Where is the problem?
    I suppressed xcopy output. Just want to know what should be done for unmapping the drive.
    "When you hit a wrong note it's the next note that makes it good or bad". Miles Davis

  • #2
    Re: net use: cannot delete mapped drive

    drive name only; net use S: /d

    Comment


    • #3
      Re: net use: cannot delete mapped drive



      Thanks.
      "When you hit a wrong note it's the next note that makes it good or bad". Miles Davis

      Comment


      • #4
        Re: net use: cannot delete mapped drive

        FYI

        An other way to map a network drive is by using "PushD".
        PushD is basically changing the current working directory to the specified directory (like: cd/d does). If the target is an unc path then PushD automatically assign an available driveletter (like: Net use * does). So PushD can do both at the same time.
        With PopD you can delete the drive mapping automatically that was previously made by PushD.

        The benefit of using PushD is that it always uses a free drive letter (btw it only assign a driveletter if the target is an unc path, because an unc map can not set as the working directory), and set the target as the active folder. In combination with PopD - the mappping can be automatically deleted again - then the worling directory will be exact as it was just before the previous PushD.

        It will be even more safe if you use the conditional processing symbols && after PushD. Then the (commands) following && do run only if the command preceding the symbols is successful.

        e.g.
        Code:
        @echo off
        
        :: variables
        Set "_Source=\\KY\Company"
        Set "_Destination=f:\Public - Users - CIE\Mon - Lun\CSF"
        
        If not exist "%_Destination%" MD "%_Destination%"
        
        PushD "%_Source%" &&(
         xcopy *.* "%_Destination%" /d/e/v/y
        PopD )

        But... in your case a drive mapping is not nessesary ,
        Just simply
        Code:
        xcopy "\\KY\Company\*.*" "f:\Public - Users - CIE\Mon - Lun\CSF\" /d/e/v/y
        should work too.


        \Rems

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment

        Working...
        X