Using a volume serial number for partitions?

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

Using a volume serial number for partitions?

Post by highend » 20 Apr 2015 13:21

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: 950
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: Using a volume serial number for partitions?

Post by yusef88 » 20 Apr 2015 15:02

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: 9006
Joined: 06 Feb 2011 00:33

Re: Using a volume serial number for partitions?

Post by highend » 20 Apr 2015 18:49

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: 1084
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil » 21 Apr 2015 13:11

highend, that's a very useful script!- even more portability!!. :D
can you please add a script to get this serial easily?

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

Re: Using a volume serial number for partitions?

Post by highend » 21 Apr 2015 13:40

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: 1084
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil » 21 Apr 2015 14:16

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.

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

Re: Using a volume serial number for partitions?

Post by highend » 21 Apr 2015 15:06

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: 1084
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil » 21 Apr 2015 15:33

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

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

Re: Using a volume serial number for partitions?

Post by highend » 21 Apr 2015 16:01

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

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

Re: Using a volume serial number for partitions?

Post by SammaySarkar » 21 Apr 2015 16:10

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: 1084
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil » 21 Apr 2015 16:12

=)
Attachments
04-21_171038.png
04-21_171038.png (7.08 KiB) Viewed 2364 times

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

Re: Using a volume serial number for partitions?

Post by highend » 21 Apr 2015 16:39

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: 1084
Joined: 13 Jan 2011 19:44

Re: Using a volume serial number for partitions?

Post by eil » 21 Apr 2015 16:46

so simple that i feel ashamed. :oops:

Post Reply