map external drive and remap internal drive or substitute a folder

Page 1 of 2 12 LastLast

  1. Posts : 17
    W10 W8.1 W7
       #1

    map external drive and remap internal drive or substitute a folder


    I have a SSD for C: and internal Drive D:

    I would like to create 2 batch files that I start manually.

    How to:
    1. If I connect my external drive I want the internal drive become E: and the external should be D:

    On another PC:
    2. Let's say I have a folder C:\folder1\folder2.
    If I connect my external drive I want it to be mapped to C:\folder1. So if I have the ext. drive connected its root directory shows up instead of folder2.
      My Computer


  2. Posts : 4,779
    Windows 11 Pro 64 Bit 22H2
       #2

    I'm confused? You mentioned an SSD drive and an internal D: drive, you have not mentioned an External drive in your opening sentence. Is the SSD considered your Internal drive in the 1. statement? If you boot into Windows on the SSD drive, it cannot have it's drive letter changed from C: You can Change your Drive letter for your external drive to always be D: when you connect it in Disk Management, by changing the Drive letter of your internal D: drive to something else then changing the External drive letter to D:
    When you connect an External drive, it will take the last Drive letter it had or that you assigned to it. You cannot Map an external drive to a folder on C:
      My Computer


  3. Posts : 18,430
    Windows 11 Pro
       #3

    spunk said:
    You cannot Map an external drive to a folder on C:
    Yes, you can. But the folder you want to map it to on C: drive must be empty first. I only know how to do it in disk management. I don't know how to do it in command prompt or powershell. You can even have the external drive have a drive letter AND be mounted to a folder on C: drive at the same time!

    map external drive and remap internal drive or substitute a folder-capture.jpg

    map external drive and remap internal drive or substitute a folder-capture1.jpg
      My Computer


  4. Posts : 4,187
    Windows 11 Pro, 22H2
       #4

    You can script a simple set of diskpart commands to accomplish this but I too am a little confused by some of the details in your post so I'll talk in general terms.

    In diskpart, to assign a drive to a disk you select the disk and then perform a "assign letter=<letter>". To assign a mount point it is "assign mount=<path>".

    There's even a simple trick to avoid creating a seperate text file for diskpart from which it would read the parameters.

    I'll post some details in a few minutes, but in the meantime, if you could clarify the original post it would be appreciated.
      My Computers


  5. Posts : 4,187
    Windows 11 Pro, 22H2
       #5

    From a batch file, you can run diskpart commands like this:

    Place the following in the batch file:

    Code:
    diskpart /s diskpart.txt
    The result is that diskpart will be called and run the commands contained in the text file called "diskpart.txt".

    In the diskpart.txt file simply place commands like this:


    Code:
    select disk 2
    assign letter=e
    select disk 3
    assign mount=c:\MountPoints\Vol1
    exit

    A trick to avoid the need for any external text file:

    Place all your diskpart commands between parenthesis with echo commands and pipe the output to diskpart on the last line as in this example:


    Code:
    (echo select disk 2
    echo assign letter=e
    echo select disk 3
    echo assign mount=c:\MountPoints\Vol1
    echo exit
    ) | diskpart > nul

    Naturally, you can use replaceable parameters in your batch file and add all kinds of logic to determine the correct disk ID, etc.
      My Computers


  6. Posts : 18,430
    Windows 11 Pro
       #6

    You can't assign letters and mount points to disks. You can only assign them to partitions.
      My Computer


  7. Posts : 4,187
    Windows 11 Pro, 22H2
       #7

    Thanks for the catch. I was rushing and didn't think that through completely.
      My Computers


  8. Posts : 17
    W10 W8.1 W7
    Thread Starter
       #8

    THX to all of you !!! (C: is my disk 0 and has the w10 partition on it)

    hsehestedt said:
    .........
    Code:
    select disk 1
    assign letter=e
    select disk 2
    assign letter=d
    select volume 1
    assign mount=c:\MountPoints\Vol1
    exit

    Add Info: My external drive (E:) only has one partition named "ext_data"

    I played around with diskpart, but did not find a solution for:

    a) How can I be sure to mount exactly the partition named "ext_data" (without using the GUID like in mountvolume)

    b) How can I autostart the script as soon as my external drive is connected or disconnected
      My Computer


  9. Posts : 4,187
    Windows 11 Pro, 22H2
       #9

    To make sure you select the correct volume you can do a "list vol" in diskpart. You can have your batch file parse that to get the correct volume ID for the volume with the label "ext_data".

    As for starting it automatically, I'm just guessing here, but you could probably set a condition in task scheduler to trigger the running of a batch file when a disk is connected / disconnected from the system but that would need further research.
      My Computers


  10. Posts : 17
    W10 W8.1 W7
    Thread Starter
       #10

    THX, I will check the idea with the scheduler

    Can you please give me help regarding the parsing ... I am a newby on those things ;-)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:24.
Find Us




Windows 10 Forums