on error resume next
Dim fso, WshShell
'*****************
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
'***********************
drive_to_remap = "f:" ' Change to your letter to change
Set d = fso.GetDrive(drive_to_remap) 'Check if the drive exist
If Err Then
err.clear
else
if d.DriveType = 1 then ' 1 = removable drive
'Create a Text file to call with diskpart(From XP) to
change the drive letter
fso.createtextfile("c:\temp\diskpartscript.txt")
set script_file =
fso.OpenTextFile("c:\temp\diskpartscript.txt",2,true)
script_file.WriteLine "Select Volume " &
drive_to_remap
script_file.WriteLine "Assign"
script_file.WriteLine "Exit"
wshshell.run "diskpart /s
c:\temp\diskpartscript.txt",1,1
end if
end if