Using a volume serial number for partitions?

Features wanted...
Post Reply
highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Using a volume serial number for partitions?

Post by highend »

Don,

can you add the support for targeting partitions via their volume serial number instead of only the drive letter?

Maybe in the form of: {1ECD-8A2C}\

E.g.

Code: Select all

goto "{1ECD-8A2C}\Backup";
It doesn't matter that much for a stationary device because you can use USBDLM to mount a partition to a specific drive letter but on a different PC (and e.g. without admin rights) it would be a great help to be able to get to the correct partition via it's serial and not a drive letter...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

yusef88
Posts: 1123
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Using a volume serial number for partitions?

Post by yusef88 »

not sure if they are the same thing
admin wrote:
yusef88 wrote:why xyplorer doesn't handle location like this ?

Code: Select all

\\?\Volume{64CF0AD5-AEE6-11E4-9712-806E6F6E6963}\boot.ini
1. Not supported ATM.

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Using a volume serial number for partitions?

Post by highend »

In the meantime:

Code: Select all

$serial = "1ECD-8A2C"; // 2 TB internal drive (normally on T:)
    goto resolveVolumeSerialNumber($serial);

// Resolve the volume serial number of a partition into the corresponding drive letter
function resolveVolumeSerialNumber($volumeSerialNumber) {
    foreach($drive, get("drives")) {
        $drive = trim($drive, "\", "R");
        $serial = regexmatches(runret("cmd /c vol $drive", "%windir%"), "[A-Z0-9]{4}-[A-Z0-9]{4}");
        if ($serial == $volumeSerialNumber) { return $drive; }
    }
    return "<curpath>";
}
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil »

highend, that's a very useful script!- even more portability!!. :D
can you please add a script to get this serial easily?
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Using a volume serial number for partitions?

Post by highend »

This function returns the serial for one, multiple or all drives depending on what you submit.
Multiple drives must be separated via "|".
It returns "NO SERIAL" if a drive doesn't have one or if the drive is empty. E.g. your DVD-Drive returns
none if no CD / DVD is in it.

You can use:
- The drive letter only
- The drive letter with a trailing ":" or ":\"

Code: Select all

text getVolumeSerialNumber();
    text getVolumeSerialNumber("D");
    text getVolumeSerialNumber("C:|D:")

// Returns the volume serial number for a single / multiple / all drive letter(s)
function getVolumeSerialNumber($driveLetters) {
    $drives = get("drives");
    $output = "";
    if !($driveLetters) { $driveLetters = $drives; }
    foreach($drive, $driveLetters) {
        if (strlen($drive) == 1) { $drive = "$drive:"; }
        $drive = trim($drive, "\", "R");
        $serial = regexmatches(runret("cmd /c vol $drive", "%windir%"), "[A-Z0-9]{4}-[A-Z0-9]{4}");
        if !($serial) { $serial = "NO SERIAL"; }
        $output = $output . "$drive - $serial<crlf>";
    }
    return $output;
}
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil »

can't figure out what's wrong, i get this

Code: Select all

Could not find: 
D:\Progs\XYplorer\resolveVolumeSerialNumber(A2F3-1530)
when i try to use 1st script with serial of volume 2st script provided me.
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Using a volume serial number for partitions?

Post by highend »

Show your modified 1st script... Maybe you invoked the function with resolveVolumeSerialNumber(A2F3-1530) instead of resolveVolumeSerialNumber("A2F3-1530")?

Which version of XY do you use?
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil »

Code: Select all

$serial = "A2F3-1530"; // 2 TB internal drive (normally on T:)
    goto resolveVolumeSerialNumber($serial);

 // Resolve the volume serial number of a partition into the corresponding drive letter
 function resolveVolumeSerialNumber($volumeSerialNumber) {
    foreach($drive, get("drives")) {
        $drive = trim($drive, "\", "R");
        $serial = regexmatches(runret("cmd /c vol $drive", "%windir%"), "[A-Z0-9]{4}-[A-Z0-9]{4}");
        if ($serial == $volumeSerialNumber) { return $drive; }
    }
    return "<curpath>";
 }
15.00.500
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Using a volume serial number for partitions?

Post by highend »

15.00.500
This version doesn't even exist :)
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Using a volume serial number for partitions?

Post by bdeshi »

it does: www.xyplorer.com/download.php
the beta topic doesn't update when .#00 versions are released.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil »

=)
Attachments
04-21_171038.png
04-21_171038.png (7.08 KiB) Viewed 4840 times
Win 7 SP1 x64 100% 1366x768

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Using a volume serial number for partitions?

Post by highend »

Oh^^

Code: Select all

function resolveVolumeSerialNumber($volumeSerialNumber) {
   foreach($drive, get("drives")) {
       $drive = trim($drive, "\", "R");
       $serial = regexmatches(runret("cmd /c vol $drive", "%windir%"), "[A-Z0-9]{4}-[A-Z0-9]{4}");
       if ($serial == $volumeSerialNumber) { return $drive; }
   }
   return "<curpath>";
}
You've somehow indented this part of the code, that's the reason why it doesn't work. A line that defines a function can't be indented. So make sure you delete your single spaces before it.
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

eil
Posts: 1609
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil »

so simple that i feel ashamed. :oops:
Win 7 SP1 x64 100% 1366x768

Post Reply