Paypal donations are always accepted :D
Code: Select all
/* 04.08.2011, change drive letters
::load "<xyscripts>\ChangeDriveLetter.xys";
Remarks: XYplorer must have been started with admin rights. As an alternative you could create a task with highest privileges that
executes the VBScript file and can be called with a temporary batch file (like schtasks /run /tn "ChangeDriveLetter"). A third way
would be the use of psexec but it requires a small bit of configuration on your pc (enable Administrator account, give it a password,
etc.). See http://technet.microsoft.com/de-de/sysinternals/bb897553 for further details.
*/
"_Initialize"
global $SelectedDriveLetter, $DestinationDriveLetter, $ExcludedDriveLetters, $AvailableDriveLetters, $UsedDriveLetters, $VBSTempScriptFile;
// Please change only the $ExcludedDriveLetters variable to fit your needs.
// Don't forget to add the colon and the | character after each drive letter
$ExcludedDriveLetters = "A:|B:|";
// Don't change anything in the script below this point
$SelectedDriveLetter = "";
$DestinationDriveLetter = "";
$UsedDriveLetters = "";
$AvailableDriveLetters = "A:|B:|C:|D:|E:|F:|G:|H:|I:|J:|K:|L:|M:|N:|O:|P:|Q:|R:|S:|T:|U:|V:|W:|X:|Y:|Z:|";
$VBSTempScriptFile = "%temp%\~ChangeDriveLetter.vbs";
"Change drive letter for...|<xypath>\.Icons\RSync_Upload.ico|1"
;
"... ¤t drive"
global $CurrentSelectedMenuItem;
sub "_Initialize";
$CurrentSelectedMenuItem = "current_drive";
sub "_Main";
status "Changed drive letter successfully";
"... &select drive"
global $CurrentSelectedMenuItem;
sub "_Initialize";
$CurrentSelectedMenuItem = "selected_drive";
sub "_Main";
status "Changed drive letter successfully";
"- : Separator"
"Cancel"
"- : Separator"
"Edit this &script : edit"
self $ScriptFile, file;
openwith "<xydrive>\Tools\EditPlus\editplus.exe", ,$ScriptFile;
/*
Functions
*/
"_Main"
global $SelectedDriveLetter, $DestinationDriveLetter, $ExcludedDriveLetters, $AvailableDriveLetters, $UsedDriveLetters, $VBSTempScriptFile;
global $CurrentSelectedMenuItem;
// Remove the $ExcludedDriveLetters from $AvailableDriveLetters
foreach($Drive, $ExcludedDriveLetters, "|") {
if($Drive == "") { break; }
$Drive = $Drive . "|";
$AvailableDriveLetters = replace($AvailableDriveLetters, "$Drive", "");
}
// Find all used drive letters
// Create new tab and go to the "Computer" node
tab("new", "Computer");
// Report the names for all drives
$UsedDriveLettersNames = report("{name}|");
// Make a new "|" separated $UsedDriveLetters list
foreach($Item, $UsedDriveLettersNames, "|") {
if($Item == "") { break; }
$DriveLetter = regexreplace($Item, "(.*\()([A-Za-z]:)(.*)", "$2");
// Get single used drive letters to remove them from the $AvailableDriveLetters list
$DriveLetterWithSeparator = $DriveLetter . "|";
// Build $UsedDriveLetters list for later use
$UsedDriveLetters = $UsedDriveLetters . $DriveLetter . "|";
// Remove the $UsedDriveLetters from $AvailableDriveLetters
$AvailableDriveLetters = replace($AvailableDriveLetters, "$DriveLetterWithSeparator", "");
}
// Close current tab
#351;
// Change drive letter for... current drive
if($CurrentSelectedMenuItem == "current_drive") {
$CurrentPath = "<curpath>";
$SelectedDriveLetter = regexreplace($CurrentPath, ".*([A-Za-z]:)\\(.*)", "$1");
$DestinationDriveLetter = inputselect("Please select the destination drive letter:", "$AvailableDriveLetters", "|", 1);
}
// Change drive letter for... selected drive
if($CurrentSelectedMenuItem == "selected_drive") {
$SelectedDriveLetter = inputselect("Please select the source drive letter:", "$UsedDriveLetters", "|", 1);
$DestinationDriveLetter = inputselect("Please select the destination drive letter:", "$AvailableDriveLetters", "|", 1);
}
$SelectedDriveLetterForScript = "(" . chr(34) . "Select * from Win32_Volume Where Name = '" . $SelectedDriveLetter . "\\'" . chr(34) . ")";
$DestinationDriveLetterForScript = "objVolume.DriveLetter = " . chr(34) . $DestinationDriveLetter . chr(34);
writefile($VBSTempScriptFile, 'strComputer = "."'.<crlf>, o, ta);
writefile($VBSTempScriptFile, 'Set objWMIService = GetObject("winmgmts:" _'.<crlf>, a, ta);
writefile($VBSTempScriptFile, '& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")'.<crlf>, a, ta);
writefile($VBSTempScriptFile, <crlf>, a, ta);
writefile($VBSTempScriptFile, 'Set colVolumes = objWMIService.ExecQuery _'.<crlf>, a, ta);
writefile($VBSTempScriptFile, $SelectedDriveLetterForScript.<crlf>, a, ta);
writefile($VBSTempScriptFile, <crlf>, a, ta);
writefile($VBSTempScriptFile, 'For Each objVolume in colVolumes'.<crlf>, a, ta);
writefile($VBSTempScriptFile, $DestinationDriveLetterForScript.<crlf>, a, ta);
writefile($VBSTempScriptFile, 'objVolume.Put_'.<crlf>, a, ta);
writefile($VBSTempScriptFile, 'Next'.<crlf>, a, ta);
open "$VBSTempScriptFile";