I am trying to use a .bat file that will reassign the USB drive letter to Z regardless of which computer it is in. I have a few programs that need to keep a constant drive letter to work, and I am also trying to make this portable and easy to copy.
I currently have the .bat asking the user what drive was assigned, then I want it to select that drive and assign it to Z. Right now I am having an issue with using commands in Diskpart. It doesn't want to ask the user for input and instead just turns off. I am not sure if it is how I input it or what.
It briefly runs the script, but shuts off before I can see anything it did.After awhile of troublshooting I only placed "List Volume" in the script and I can see it flash the volumes and then shut off. I tried placing pause afterwards, but didn't have luck with that.
The script is located on the volume, in this case X So I enter X and press enter, I see a flash of volumes and then it shuts off.
This is the .Bat
Set/P VolNum=Please enter Volume number:
diskpart /s %VolNum%:\script.txt
This is the script
list volume
Pause
Set/P VolNum=Please enter Volume number:
Select Partition %VolNum%
Assign Letter=Z
The reason I have two Set/P was since a second window opened up and I was having issues. I would really prefer only one prompt.
I am fairly new to writing .bat and using diskpart automation, so try to break it down if possible.
If what I am doing is not possible, let me know and if you can think of an alternative I would appreciate it.
Thank you everyone!
I currently have the .bat asking the user what drive was assigned, then I want it to select that drive and assign it to Z. Right now I am having an issue with using commands in Diskpart. It doesn't want to ask the user for input and instead just turns off. I am not sure if it is how I input it or what.
It briefly runs the script, but shuts off before I can see anything it did.After awhile of troublshooting I only placed "List Volume" in the script and I can see it flash the volumes and then shut off. I tried placing pause afterwards, but didn't have luck with that.
The script is located on the volume, in this case X So I enter X and press enter, I see a flash of volumes and then it shuts off.
This is the .Bat
Set/P VolNum=Please enter Volume number:
diskpart /s %VolNum%:\script.txt
This is the script
list volume
Pause
Set/P VolNum=Please enter Volume number:
Select Partition %VolNum%
Assign Letter=Z
The reason I have two Set/P was since a second window opened up and I was having issues. I would really prefer only one prompt.
I am fairly new to writing .bat and using diskpart automation, so try to break it down if possible.
If what I am doing is not possible, let me know and if you can think of an alternative I would appreciate it.
Thank you everyone!