- May
- 13,117
- 180
In another thread someone asked about running a batfile when an IPOD was plugged in. Another person suggested an AUTORUN.INF in the IPOD's root directory. This made me wonder if I could get an external storage device to mount on a drive letter of my choosing. I've almost got it (all but the AUTORUN.INF part).
Supposing the AUTORUN.INF mechanism works, I'd use it to run ASSIGN.BTM which resides on the removable media:
SET current=%@left[1,%@full[%0]]
ECHO Current drive letter: %current
INPUT New drive letter:` ` %%new
ECHO New drive letter: %new
ECHO select volume %current > v:\diskpart.scr
ECHO assign letter=%new >> v:\diskpart.scr
CDD v:\
v:\assign.btm
In order for the change of letter to take place without a reboot message the removable media must not be busy. Thus ASSIGN.BTM leaves (with CDD) if necessary, and the current BTM exits when V:\ASSIGN.BTM is invoked.
V:\ASSIGN.BTM says, simply
diskpart.exe /s v:\diskpart.scr
CDD %new:\
All that works. Maybe the AUTORUN.INF part is easy (maybe impossible); I haven't tried yet.
Supposing the AUTORUN.INF mechanism works, I'd use it to run ASSIGN.BTM which resides on the removable media:
SET current=%@left[1,%@full[%0]]
ECHO Current drive letter: %current
INPUT New drive letter:` ` %%new
ECHO New drive letter: %new
ECHO select volume %current > v:\diskpart.scr
ECHO assign letter=%new >> v:\diskpart.scr
CDD v:\
v:\assign.btm
In order for the change of letter to take place without a reboot message the removable media must not be busy. Thus ASSIGN.BTM leaves (with CDD) if necessary, and the current BTM exits when V:\ASSIGN.BTM is invoked.
V:\ASSIGN.BTM says, simply
diskpart.exe /s v:\diskpart.scr
CDD %new:\
All that works. Maybe the AUTORUN.INF part is easy (maybe impossible); I haven't tried yet.