Solved

Batch File (or other script) to remap a disk drive

Posted on 2011-02-28
7
698 Views
Last Modified: 2012-05-11
Hi All,

I'm looking to be able to remap a disk drive (typically D:) to another letter via a batch (or vbs?) script.  This should either (in my mind):

  -  Unmap the physical drive
  -  Try to map the physical drive to the last available letter
OR
  -  Disable the physical drive so that the letter is released
  -  Re-Enable the physical drive on the last available letter.

I know that it can all be done via Disk Management, however, this needs to be scripted.  It is also important that (where possible) the user should NOT need to restart their PC.

Any help is appreciated!!
0
Comment
Question by:Jofnn
7 Comments
 
LVL 12

Expert Comment

by:Amick
ID: 34997968
This may get you part of the way there:

net use * \\myComputer\D$

This command assigns default share D$ to the last available drive letter.



0
 
LVL 2

Expert Comment

by:seanyc111
ID: 34998020
have a look at mode or set in cmd
(use e.g. set/? in cmd  to see how the command is used
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 150 total points
ID: 34998292
this looks promising: http://support.microsoft.com/kb/300415

in short:
use command:
diskpart /s script.txt

Open in new window


in script.txt put something like:
select disk=5
select volume=7
assign letter=x noerr

Open in new window


This will obviously only work if your starting situation is always exactly the same, use diskpart interactively to find out what the available disks and volumes are. If it's not always the same you might be able to get output from diskpart first (list volume) and parse that to create a second command file.
0
 
LVL 3

Author Comment

by:Jofnn
ID: 34998837
Hi Robert,

That's exactly what I'm looking for... I've tested the theory (by re-mapping my own disk drive) and this works... I'll build a script around that and put on here in due course!
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 35331273
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Chocolatey under PowerShell is not working properly 3 68
batch script 3 45
Batch file or script with password 22 69
Seatools For Dos (Just shows FreeDos) 21 37
It is only natural that we all want our PCs to be in good working order, improved system performance, so that is exactly how programs are advertised to entice. They say things like:            •      PC crashes? Get registry cleaner to repair it!    …
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question