VideoHelp Forum




+ Reply to Thread
Results 1 to 14 of 14
  1. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Looking to clone the system drive to a particular drive in an internal caddy using the command line.
    The particular drive needs to have a unique ID that is always the same (lest another drive has been inserted ) so that a batch file can run a check to verify that the correct drive has been inserted - something like 'If a$ = "some value" continue else error out.
    I know that drive letters, volumes and disk numbers can change when disks, flash drives etc are inserted so want to avoid results ending in tears.
    Do hard drives have a unique, non changing ID (in the Windows environment) that could be tested in a simple bat file?
    Quote Quote  
  2. Member vhelp's Avatar
    Join Date
    Mar 2001
    Location
    New York
    Search Comp PM
    You can try this dos console program out. If you can figure out how to add to a batch, then you're all set.

    diskserial

    Code:
    usage:
    diskserial [parameters]
    diskserial c, d, e, f, ... disk drive letter, one param per run
    diskserial -version    ... show version info
    https://www.virustotal.com/en/
    Quote Quote  
  3. Does that caddy have multiple slots for drives? If so then if you insert disk into different slot then it may be difficult to set a permanent disk drive letter. The system may treat that caddy like an external drive and it seems to be impossible to set permanent drive letter to external drives. I did a quick Google search on your question and didn't find much help.
    Extraordinary claims require extraordinary evidence -Carl Sagan
    Quote Quote  
  4. Member
    Join Date
    Feb 2004
    Location
    Australia
    Search Comp PM
    Serial scan will work and use system query to determine drive letter ... this way it will not matter what letter is assigned to it
    Quote Quote  
  5. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    @vhelp - thank you that saved a lot of head scratching.
    @TreeTops - No it's a single caddy and since it's connected internally I find that it consistently lists whatever drive as inserted as drive 'H'.
    I hope it stays consistent.
    @Bjs - If drive 'H' is not available it will fail so if the drive changes letter I would need some way of scanning the drives to find the one with the correct number then getting the cloning software to run with it.

    I made the following tentative test bat file and welcome comments - it does work BTW:

    diskserial H : > "C:\Users\Superuser\Desktop\serial.txt"

    set /p s= < "C:\Users\Superuser\Desktop\serial.txt"

    if not %s% == 5A5C7FCE goto fail


    AMBackup /c /t System /d H /a

    echo OK
    exit
    :fail
    echo byeee
    pause
    exit
    Last edited by sambat; 13th Oct 2015 at 16:25.
    Quote Quote  
  6. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Further to TreeTops caution on drive letters, if the caddy disk was given a different letter for some reason, running a batch file to clone a disk would result in the wrong destination disk being worked.
    Since the caddy disk has a unique Volume ID number, the batch file would have to locate the correct disk using that ID, then somehow return the disk letter before cloning starts.
    All I can think is to have a list from A to Z and have it examine the ID of each disk until it finds the correct one then 'goto' the cloning part of the batch.
    Trouble is I can't find a way of matching ID and Letter.

    Not unique:I found that the source disk ID is given to the clone, so if I cloned the C drive, the letter list would have to omit 'C'.
    I'm stumped.
    Last edited by sambat; 14th Oct 2015 at 10:33. Reason: update
    Quote Quote  
  7. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Figured it out.
    Even if the system assigns a different letter to the drive when it's plugged, the name doesn't change.
    Instead of searching by serial or letter, look for the volume name and translate that to a disk letter.
    The code, cobbled together from other peoples work, looks for the volume name and associates that with the drive letter.
    The middle part removes the colon from the letter and passes it to the standalone program which clones the system drive; at the end the drive with the cloned system is given it's original label.

    rem @echo off
    rem Look for the drive label (in this case it's 'nonsuch') instead of the volume serial ID.
    for /f "delims=" %%a in ('WMIC Path Win32_volume where "Label='nonsuch'" Get DriveLetter /format:list') do >nul 2>&1 set "SystemVolume_%%a"
    Rem Drive Letter associated with the label "nonsuch" is placed in a variable named %SystemVolume_DriveLetter%
    Rem but it has a ":" character (colon) appended, e.g. h:

    Rem delete the character string ':' ( the colon ).
    SET _test=%SystemVolume_DriveLetter%
    SET _result=%_test::=%
    ECHO %_result%

    AMBackup /c /t system /d %_result% /a /o yes

    rem reset volume label
    label %_result%: nonsuch
    exit
    Quote Quote  
  8. From CMD: wmic path win32_physicalmedia get SerialNumber
    From PowerShell: Get-WmiObject Win32_PhysicalMedia | Format-Table Tag, SerialNumber

    Those will get you the drive serial numbers but I don't know how you then map drive letter to the SN.
    Quote Quote  
  9. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    The command line doesn't work on W7 Home Edition - but booting into W7 Ultimate, the command returns some odd numbers for the first four SSD drives (lower image).
    Whereas the PowerShell command on W7 HE returns the actual manufacturers serials (eyeballed by me) and agrees with the SIW program (upper image)
    I'm not familiar with PS scripts but expect it would be possible to match the two serials to the correct source/destination drives....

    Click image for larger version

Name:	Clipboard01.jpg
Views:	881
Size:	71.7 KB
ID:	34096
    Quote Quote  
  10. The sequence of hex values "202020...." corresponds to the physical drive 0. 20 is a space, 30 is 0, 31 is 1 39 is 9, 41 is A, 42 is B, etc. Except every pair of values is reversed, a big endian vs little endian issue.

    Code:
    20 20 20 20 20 20 20 20 34 31 37 33 44 30 32 33 45 41 33 32
    in order:                4  1  7  3  D  0  2  3  E  A  3  2
    pairs swapped            1  4  3  7  0  D  3  2  A  E  2  3
    Quote Quote  
  11. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    The horror...
    In my copy of W7 Home Edition, the 'get' capabilities for 'diskdrive' have no listing suggesting serial numbers, so I can't use that method for finding the mfg. serial number (I get ' Invalid XML content' message when using the original suggestion) and since I don't know how to create batch files for PowerShell, I'm going to leave it as is.

    Note that there is a so called 'hotfix' addressing the XML message, but installing it made no diff.
    Many thanks for the information about 'endians', now those numbers make more sense.


    C:\Windows\System32>wmic diskdrive get /?

    Property get operations.
    USAGE:

    GET [<property list>] [<get switches>]
    NOTE: <property list> ::= <property name> | <property name>, <property list>

    The following properties are available:
    Property Type Operation
    ======== ==== =========
    Availability N/A N/A
    BytesPerSector N/A N/A
    Capabilities N/A N/A
    CapabilityDescriptions N/A N/A
    CompressionMethod N/A N/A
    ConfigManagerErrorCode N/A N/A
    ConfigManagerUserConfig N/A N/A
    DefaultBlockSize N/A N/A
    Description N/A N/A
    DeviceID N/A N/A
    ErrorCleared N/A N/A
    ErrorDescription N/A N/A
    ErrorMethodology N/A N/A
    Index N/A N/A
    InstallDate N/A N/A
    InterfaceType N/A N/A
    LastErrorCode N/A N/A
    Manufacturer N/A N/A
    MaxBlockSize N/A N/A
    MaxMediaSize N/A N/A
    MediaLoaded N/A N/A
    MediaType N/A N/A
    MinBlockSize N/A N/A
    Model N/A N/A
    Name N/A N/A
    NeedsCleaning N/A N/A
    NumberOfMediaSupported N/A N/A
    PNPDeviceID N/A N/A
    Partitions N/A N/A
    PowerManagementCapabilities N/A N/A
    PowerManagementSupported N/A N/A
    SCSIBus N/A N/A
    SCSILogicalUnit N/A N/A
    SCSIPort N/A N/A
    SCSITargetId N/A N/A
    SectorsPerTrack N/A N/A
    Signature N/A N/A
    Size N/A N/A
    Status N/A N/A
    StatusInfo N/A N/A
    SystemName N/A N/A
    TotalCylinders N/A N/A
    TotalHeads N/A N/A
    TotalSectors N/A N/A
    TotalTracks N/A N/A
    TracksPerCylinder N/A N/A

    The following GET switches are available:

    /VALUE - Return value.
    /ALL(default) - Return the data and metadata for the attribute.
    /TRANSLATE:<table name> - Translate output via values from <table name>.
    /EVERY:<interval> [/REPEAT:<repeat count>] - Returns value every (X interval) se
    conds, If /REPEAT specified the command is executed <repeat count> times.
    /FORMAT:<format specifier> - Keyword/XSL filename to process the XML results.

    NOTE: Order of /TRANSLATE and /FORMAT switches influences the appearance of outp
    ut
    .
    Quote Quote  
  12. Originally Posted by sambat View Post
    The horror...
    In my copy of W7 Home Edition, the 'get' capabilities for 'diskdrive' have no listing suggesting serial numbers, so I can't use that method for finding the mfg. serial number
    I've read elsewhere that it doesn't work with some versions of Windows. But I get exactly the same list from Home Premium (and it does return serial numbers) so I think it's canned text, not a list of exactly what's available on a particular system. Older drives didn't have individual serial numbers. I think it was around 10 years ago that manufacturers started adding them.

    You can run a PowerShell script from a batch file and redirect output to a temp file. Then parse the temp file from your batch file.
    Quote Quote  
  13. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    I verified the non-existance of Get 'Diskdrive' on a Win10 PC listing - that notwithstanding, the command worked correctly.

    There is a way to bypass the error I get on W7 HE, if you know the Disk number (e.g. Disk0 being system or C ) of the drive, you can use:

    wmic path win32_physicalmedia where tag='\\\\.\\PHYSICALDRIVE0' get serialnumber /format:list

    Note the six backslashes in front of the drive number.
    The image shows the serial for my Disk 3, which is correct.
    So a batch file would verify the source and destination of a cloning using the unchanging manufaturers serial#.

    Click image for larger version

Name:	Clipboard02.jpg
Views:	936
Size:	14.8 KB
ID:	34099
    Quote Quote  
  14. Member
    Join Date
    Dec 2005
    Location
    Canada
    Search Comp PM
    Since I'm beating this to death, maybe someone can explain the why of this: run the command as a user and get the long little/big endian version or as an admin and get human readable version of the same serial number.

    Click image for larger version

Name:	hc.jpg
Views:	1781
Size:	44.1 KB
ID:	34105
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!