Question

I am writing a PowerShell script that will back up several folders from my Vista drive to an external USB drive, using robocopy.
Windows does not guarantee that it will always assign the same drive letter to the external drive.
What is the best way to get around this problem?
How do I code the destination paths?

Thanks.

Was it helpful?

Solution

Windows could change that drive letter assigned to your USB drive.
The correct way to do this backup is mounting the USB drive in an empty directory. Not only does it add some consistency to swapped storage, it also allows for a persistent shortcut on a Windows desktop.

That's how to:

  1. Run "diskmgmt.msc" from Windows' Run/Start Search box,
  2. Right-click on your plugged-in drive and choose "Change Drive Letter and Paths."
  3. Remove the current drive letter assigned to your drive.
  4. Click on the Add button
  5. Select Mount into the following empty NTFS folder and click on browse.
  6. Now navigate to the subfolder that you want to assign the USB drive to and confirm the assignment.

The USB drive will from now on be accessible from that folder (if it is connected to the computer of course).
Now you can change your script to select, as destination folder, the folder with the mounted drive and forget the drive letter persistence.

OTHER TIPS

Use can use "Drive Letter View" available free at http://www.nirsoft.net/utils/drive_letter_view.html to assign desired drive letter to external drive. From this moment on, the selected removable media will always be mounted with same letter. (Test with windows 8.1)

Towards commercial side "Zentimo storage" at http://www.zentimo.com is the best solution.

or

Use Diskpart diskpart> list volume

select volume n assign letter=T i.e the new letter.

Are you sure it's impossible? (I don't have an external hard drive to test now). I think that if you right-click on "computer", then select manage, you can select a letter for an hard drive that will allways be the same for this disk.

However, can't you use the serial number of the disk?

(sorry if my explanations weren't well explained, I'm not a native english speaker)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top