Solved

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

Posted on 2011-02-28
7
695 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bash script to unzip a file 5 50
robocopy vs xcopy vs copy 8 108
Event ID: 1202 / Source: SceCli 6 106
Windows batch files 3 52
Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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