Code: Select all
// Resolve the volume serial number and return the corresponding drive letter
function resolveVolumeSerialNumber($vsn) {
foreach($drive, get("drives")) {
$drive = trim($drive, "\", "R");
$match = regexmatches(runret("cmd /c vol $drive", "%windir%"), "[A-Z0-9]{4}-[A-Z0-9]{4}");
if ($match == $vsn) { return $drive; }
}
return "";
}How should the last return statement look like (I guess the best way is to return an empty string)?
- return;
- return "";
- remove it?
The call to the function looks like:
Code: Select all
$serial = "1ECD-8A2C";
$dst = resolveVolumeSerialNumber($serial);
if ($dst) { goto $dst; }
Is there a better way to handle either the call or the function itself?
XYplorer Beta Club