Solved

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

Posted on 2011-02-28
7
691 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now