Gents

I have solved this myself - after a fashion.  The drive reservations are stored in 
HKLM\system\mounteddevices  The reservations for the original card reader are still 
there along with the letter allocation for the new reader in each machine.

Each drive has a huge binary value attached to it, although most of that is encoded 
text saying that it is a removable drive, some of it is an ID number specific to the 
individual drive (that is each physical drive, not each type - a bit like a guid)

Copying the value from the default drive letter to the reserved letter, deleting the 
unwanted value & then rebooting is sufficient to change the registered drive letter.

With 4 drives over 94 machines I felt a script was needed - although it is very 
specific to my build, the principle might be useful to someone else out there.  Just 
to be clear I am changing the default drive letters D,E,F,G to the reserved letters 
T,U,V,W so that there is no clash with our mapped drives.

The script is fairly low quality, it is the first perl script that I have written from 
scratch, so error checking is basic, &  there is much room for optimisation but I 
needed to write it quickly.

Hope it helps someone

Regards

Kevin Lawry

____________________script starts_________________________


# Script change drive mapping on whitestar machines for card readers

use warnings;
use strict;
use Getopt::Long;


use Win32::TieRegistry (Delimiter => '/');
my $drive_mount_key= $Registry->{"LMachine/System/MountedDevices/"}
        or die "failed here";

#my $drive_mount_key ='HKEY_LOCAL_MACHINE/SYSTEM/MountedDevices/';

# get initial value

        my $valueDDrive= $drive_mount_key->GetValue("\\DosDevices\\D:")
                or die "failed";

        my $valueEDrive= $drive_mount_key->GetValue("\\DosDevices\\E:")
                or die "failed";

        my $valueFDrive= $drive_mount_key->GetValue("\\DosDevices\\F:")
                or die "failed";

        my $valueGDrive= $drive_mount_key->GetValue("\\DosDevices\\G:")
                or die "failed";
    

# set the new values

        my $result = 
$drive_mount_key->SetValue("\\DosDevices\\T:",$valueDDrive,"REG_BINARY")
                or die "failed updating T";
        $result = 
$drive_mount_key->SetValue("\\DosDevices\\U:",$valueEDrive,"REG_BINARY")
                or die "failed updating U";
        $result = 
$drive_mount_key->SetValue("\\DosDevices\\V:",$valueFDrive,"REG_BINARY")
                or die "failed updating V";
        $result = 
$drive_mount_key->SetValue("\\DosDevices\\W:",$valueGDrive,"REG_BINARY")
                or die "failed updating W";



# delete keys from here
        $result=delete $drive_mount_key->{"\\DosDevices\\D:"}
                or die "failed deleting D";
        $result=delete $drive_mount_key->{"\\DosDevices\\E:"}
                or die "failed deleting E";
        $result=delete $drive_mount_key->{"\\DosDevices\\F:"}
                or die "failed deleting F";
        $result=delete $drive_mount_key->{"\\DosDevices\\G:"}
                or die "failed deleting G";     
    


____________________script ends___________________________

-----Original Message-----
From: Administrator 
Sent: 31 July 2003 13:26
To: [EMAIL PROTECTED]
Subject: [Unattended] Changing Drive letter of USB drives


Help!

I have just taken delivery of 94 PC's with built in usb card slots, only to find that 
the drive letters I reserved in the ghost image are reserved but not for the installed 
device (I assume the usb device has an identifier and that the letters are reserved 
for the specific device that was installed in my test machine).

I can enumerate the drives using WMI & see all the details apart from the drive 
letters, and diskpart only sees the physical hard disk & not the card slots.

Can anyone suggest how I can script changing the drive letter on the 4 card drives?

Thanks

Kevin Lawry


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
unattended-info mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unattended-info

Reply via email to