ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Map Drive Script - Check for Drive letter in use

    IT Discussion
    drive mapping batch script scripting
    9
    23
    4.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403 @gjacobse
      last edited by

      @gjacobse said in Map Drive Script - Check for Drive letter in use:

      @DustinB3403 said in Map Drive Script - Check for Drive letter in use:

      @gjacobse said in Map Drive Script - Check for Drive letter in use:

      @Danp said in Map Drive Script - Check for Drive letter in use:

      http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists

      Thanks - That points in the right direction I want to go.

      However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the

      if exist f: net use n: \\unc\share
      

      I had planned to use won't work.

      Wouldn't this result in the shares being double connected to, but as a new letter each time?

      Why not just disconnect the share with

      objNetwork.RemoveNetworkDrive "M:", TRUE, TRUE
      

      And then let the script remap the drive to the original letter?

      I don't think it would double map. If the drive does exist, then map it as N, otherwise it would / could map as F.

      Not as in double like that but to explain

      M: is mapped to datashare1
      login request hits
      M: exists ok, go map the datashare1 as N: now.

      gjacobseG 1 Reply Last reply Reply Quote 0
      • momurdaM
        momurda
        last edited by

        I think the first M: would be an empty sd card reader or something similar
        It exists, so the network share would be mapped to N:

        Least that is what I imagined he wants to do.

        gjacobseG 1 Reply Last reply Reply Quote 1
        • gjacobseG
          gjacobse @DustinB3403
          last edited by

          @DustinB3403 said in Map Drive Script - Check for Drive letter in use:

          @gjacobse said in Map Drive Script - Check for Drive letter in use:

          @DustinB3403 said in Map Drive Script - Check for Drive letter in use:

          @gjacobse said in Map Drive Script - Check for Drive letter in use:

          @Danp said in Map Drive Script - Check for Drive letter in use:

          http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists

          Thanks - That points in the right direction I want to go.

          However I just ran into a wall with it. Disk Management reports the drives (E;F;G;H) as being assigned. However Windows Explorer does not. Therefore, the

          if exist f: net use n: \\unc\share
          

          I had planned to use won't work.

          Wouldn't this result in the shares being double connected to, but as a new letter each time?

          Why not just disconnect the share with

          objNetwork.RemoveNetworkDrive "M:", TRUE, TRUE
          

          And then let the script remap the drive to the original letter?

          I don't think it would double map. If the drive does exist, then map it as N, otherwise it would / could map as F.

          Not as in double like that but to explain

          M: is mapped to datashare1
          login request hits
          M: exists ok, go map the datashare1 as N: now.

          Right, however in this case it would be

          F: = CompactFlash drive
          F: exist, map datashare as N:

          1 Reply Last reply Reply Quote 0
          • gjacobseG
            gjacobse @momurda
            last edited by

            @momurda said in Map Drive Script - Check for Drive letter in use:

            I think the first M: would be an empty sd card reader or something similar
            It exists, so the network share would be mapped to N:

            Least that is what I imagined he wants to do.

            Exactly

            1 Reply Last reply Reply Quote 0
            • DustinB3403D
              DustinB3403
              last edited by

              So is the goal here to just always map the share and not care about the drive letter?

              gjacobseG 1 Reply Last reply Reply Quote 0
              • gjacobseG
                gjacobse @DustinB3403
                last edited by

                @DustinB3403 said in Map Drive Script - Check for Drive letter in use:

                So is the goal here to just always map the share and not care about the drive letter?

                Preferably not. But in some cases, you have to adjust the company standard until the standard is changed. If you have a standard of:

                F: = \\unc\shared
                H: = \\unc\home
                

                Since E-H are the Media bay, they can't be used as the company standard, so, new script for those (few) computers with media bays to move the SHARED and HOME drives to available lettes.

                1 Reply Last reply Reply Quote 0
                • momurdaM
                  momurda
                  last edited by momurda

                  Is the compact flash drive or other empty media card drives ever going to be used?
                  Some of the computers here have them, but ill be damned if I have ever seen one in use. We do use portable usb with CF or SD slots in them, but the ones built into the case are never used I think.

                  If the situation is the same wher eyou are, I think you could delete them if they exist (if exist m: net use m: //delete) then map the network drive normally. Or you can use GP to replace/update drive letters

                  gjacobseG 1 Reply Last reply Reply Quote 0
                  • gjacobseG
                    gjacobse @momurda
                    last edited by

                    @momurda said in Map Drive Script - Check for Drive letter in use:

                    Is the compact flash drive or other empty media card drives ever going to be used?
                    Some of the computers here have them, but ill be damned if I have ever seen one in use. We do use portable usb with CF or SD slots in them, but the ones built into the case are never used I think.

                    If the situation is the same wher eyou are, I think you could delete them if they exist (if exist m: net use m: //delete) then map the network drive normally. Or you can use GP to replace/update drive letters

                    You could delete them if they 'existed'. Windows Explorer does not list them. But Disk Management does.

                    One option mentioned was to disconnect them if not to be used... problem solved.

                    momurdaM 1 Reply Last reply Reply Quote 0
                    • momurdaM
                      momurda @gjacobse
                      last edited by

                      @gjacobse
                      Yea you could just unplug the usb header on the mobo.

                      DashrenderD 1 Reply Last reply Reply Quote 0
                      • DashrenderD
                        Dashrender @momurda
                        last edited by

                        @momurda said in Map Drive Script - Check for Drive letter in use:

                        @gjacobse
                        Yea you could just unplug the usb header on the mobo.

                        This or find the powershell script and object names that allow you to find remove the drive letter mapping.

                        1 Reply Last reply Reply Quote 0
                        • DashrenderD
                          Dashrender
                          last edited by

                          All of this seems like a lot of hard word versus (with management approval) an email stating -

                          Starting tomorrow, what used to be the F: drive will now be mapped as the P: drive and what was the H: will now be the R: drive.
                          Please be aware that any scripts currently using the F: or H: mappings will need to be updated to the new location. Instead of using P: or R:, please use \servername\sharename1 for P: and \servername2\sharename2 for R: This will prevent you from having to update these scripts in the future in the event that these drive letters will need to change.

                          -IT.

                          DustinB3403D 1 Reply Last reply Reply Quote 1
                          • DustinB3403D
                            DustinB3403 @Dashrender
                            last edited by

                            @Dashrender I agree, yet still don't understand the reason for using drive letters in the local drive space that is normally accessed by windows when connecting local storage.

                            Start from Z and go backwards for any shares.

                            DashrenderD 1 Reply Last reply Reply Quote 0
                            • thwrT
                              thwr @Danp
                              last edited by

                              @Danp said in Map Drive Script - Check for Drive letter in use:

                              http://stackoverflow.com/questions/27246899/batch-check-if-mapped-network-drive-exists

                              Seems to work too:
                              http://stackoverflow.com/questions/24060404/check-if-drive-letter-exists-in-batch-or-else-goto-another-piece-of-code

                              1 Reply Last reply Reply Quote 0
                              • DashrenderD
                                Dashrender @DustinB3403
                                last edited by

                                @DustinB3403 said in Map Drive Script - Check for Drive letter in use:

                                @Dashrender I agree, yet still don't understand the reason for using drive letters in the local drive space that is normally accessed by windows when connecting local storage.

                                Start from Z and go backwards for any shares.

                                It's not greenfield, I'm sure Gene is working from a setup someone else built 15+ years ago before PCs came with all those stupid memory card slots that suck up a letter but don't map into explorer like he mentions.

                                coliverC 1 Reply Last reply Reply Quote 1
                                • coliverC
                                  coliver @Dashrender
                                  last edited by

                                  @Dashrender said in Map Drive Script - Check for Drive letter in use:

                                  @DustinB3403 said in Map Drive Script - Check for Drive letter in use:

                                  @Dashrender I agree, yet still don't understand the reason for using drive letters in the local drive space that is normally accessed by windows when connecting local storage.

                                  Start from Z and go backwards for any shares.

                                  It's not greenfield, I'm sure Gene is working from a setup someone else built 15+ years ago before PCs came with all those stupid memory card slots that suck up a letter but don't map into explorer like he mentions.

                                  I'm sure it was setup longer then 15 years ago sadly.

                                  1 Reply Last reply Reply Quote 0
                                  • DanpD
                                    Danp
                                    last edited by

                                    How about this to get all drive letters in use?

                                    for %i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @%i: 2>nul && set/pz=%i <nul

                                    source

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      Jason Banned
                                      last edited by

                                      GPP can be set to use the next available drive.

                                      1 Reply Last reply Reply Quote 0
                                      • Mike DavisM
                                        Mike Davis
                                        last edited by

                                        how many computers have the card readers? Instead of messing with the rest of the company's drive letters you could script something like:

                                        diskpart
                                        select vol g
                                        assign letter=b

                                        You have to put the diskpart commands in .txt file and then specify that as the script for diskpart to use, but you get the idea. Just move the local media card reader to a letter that's not used by the company and be done with it.

                                        1 Reply Last reply Reply Quote 0
                                        • 1
                                        • 2
                                        • 1 / 2
                                        • First post
                                          Last post