[Resolved]gethdinfo not returning driveletters in WinPE

User discussion and information resource forum for scripting of TeraByte products using script lanugages such as TBScript, VBScript, Batch Files, and more.
Post Reply
nemesis
Posts: 57
Joined: Mon Jun 21, 2021 12:25 pm

[Resolved]gethdinfo not returning driveletters in WinPE

Post by nemesis »

Hi,

I'm unable to see the drive letters in the structure that is returned by gethdinfo.

A test example:
currentDisk = gethdinfo(0)
Printl(currentDisk.partition[4].drvltr)

Partition has the drive letter E in WinPE. Please advise how to retrieve the drive letters.

Is there a way to access the data on the partition without a drive letter btw?

I'd prefer to use the partition GUIDs. However all my attempts up till now have failed. If someone has example on how to do that please let me know.
Last edited by nemesis on Fri Aug 27, 2021 8:29 am, edited 1 time in total.
Regards,

Davy Vaessen
ICT+ Netherlands
nemesis
Posts: 57
Joined: Mon Jun 21, 2021 12:25 pm

Re: gethdinfo not returning driveletters in WinPE

Post by nemesis »

For the short term I've found a way around it by using:
fsi = fsinfo("E:\")
If fsi Then
printl("FS_SN:", hex(fsi.fs_sn))
printl("FS_VOLNAME:", fsi.fs_volname)
printl("FS_NAME:", fsi.fs_name)
printl("FS_CSIZE:", fsi.fs_csize)
printl("FS_SSIZE:", fsi.fs_ssize)
Else
printl("FSINFO Failed")
End If

Which works as expected. I would however expect my original solution to work as well.

For my current use case this will do however I will have some future use cases where this'll not give me the desired result so any other alternatives would be greatly appriciated!
Regards,

Davy Vaessen
ICT+ Netherlands
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: gethdinfo not returning driveletters in WinPE

Post by TeraByte Support(PP) »

Are you calling getdrvltrinfo() before calling gethdinfo()? This is required to get the drive letters.

You can mount a partition and access it without a drive letter.
Paul Purviance
TeraByte Support
nemesis
Posts: 57
Joined: Mon Jun 21, 2021 12:25 pm

Re: gethdinfo not returning driveletters in WinPE

Post by nemesis »

Can you point me to where to find how to mount it?

As for the getdrvltrinfo(), yes I do.

The related parts of the scripting.

Main.tbs:

Code: Select all

// Load the functions
include "Functions\Configuration.inc"
include "Functions\Logging.inc"
include "Functions\Disk.inc"
include "Functions\MenuBuilder.inc"
include "Functions\Terabyte\utility.inc"

Sub main()
    If DefaultsLoaded <> 1 Then
        printl("Unable to load to load the defaults. This a fatal and unrecoverable error. Please make sure the script base is complete and uncorrputed! Exiting NO ACTIONS taken. Please contact support.")
    Else
        Initialize()

        diskConfig = LoadConfigurationFile("Configuration\disk.conf")
        drives = GetDrivesInfo()
        systemDisk = IdentifySystemDisk(diskConfig, drives)
        InitScreen(systemDisk)
        ShowInstallerMainMenu(diskConfig, drives, systemDisk)

        Cleanup()
        GETKEY()
    End If

End Sub

Sub Initialize()
    InitializeLogging(LoadConfigurationFile("Configuration\logging.conf"))
    LogVerbose("Initializing the scripting", "Installation.tbs(Initialize)")

    // Prepares the drive letters for GETHDINFO, this Is active over multiple scripts
    getdrvltrinfo()
End Sub

Sub Cleanup()
    LogVerbose("Cleaning up after the script", "Installation.tbs(Cleanup)")

    // Clears the drive letters for GETHDINFO, this Is active over multiple scripts
    getdrvltrinfo(0)
End Sub
Functions\Disk.inc:

Code: Select all

include "Functions\Logging.inc"
include "Functions\Registry.inc"

Sub GetDrivesInfo()
    drives = 0
    currentDiskNumber = 0
    currentDisk = gethdinfo(currentDiskNumber)
    While currentDisk
        LogVerbose("Adding drive info for disk " # currentDisk.num, "Disk.inc(GetDrivesInfo)")

        drives[currentDiskNumber] = currentDisk
        currentDiskNumber = currentDiskNumber + 1
        currentDisk = gethdinfo(currentDiskNumber)
    wend

    drives.numberOfDrives = currentDiskNumber

    LogVerbose("Number of drives detected is " # drives.numberOfDrives, "Disk.inc(GetDrivesInfo)")
    Return drives
End Sub
Regards,

Davy Vaessen
ICT+ Netherlands
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: gethdinfo not returning driveletters in WinPE

Post by TeraByte Support(PP) »

Are you getting the drive letters now? Can't tell from the code you posted since not showing anything with the partitions.

For the mounting, you need to have the disk number and the partition id. Then use ext() to run the TBOSDT command ("mount" or "open fs", manual page 10).

Code: Select all

ext("mount 0: 0 0x01")
// e.g. ext("mount 0: " # hdnum # " " # parid)

// partition's files available using drive 0: in script

ext("umount 0:")
Note that you may also need to use the SET OPTION LOCKING command before mounting if you can't get access to the partition (normal lock or lock with dismount, manual page 28). For example, with normal locking:

Code: Select all

ext("set option locking 1")
Paul Purviance
TeraByte Support
nemesis
Posts: 57
Joined: Mon Jun 21, 2021 12:25 pm

Re: gethdinfo not returning driveletters in WinPE

Post by nemesis »

Sorry, this is the original code so no. It is not working with the code I posted. Not getting drive letters.

Thnx for the example and references
Regards,

Davy Vaessen
ICT+ Netherlands
Eric
Posts: 223
Joined: Mon Sep 05, 2011 6:53 pm
Location: France

Re: gethdinfo not returning driveletters in WinPE

Post by Eric »

Hello,
Can you try with GetDrvLtrInfo(1) instead of GetDrvLtrInfo()?
Regards
nemesis
Posts: 57
Joined: Mon Jun 21, 2021 12:25 pm

Re: gethdinfo not returning driveletters in WinPE

Post by nemesis »

Hi Eric,

thnx for the reply I tried GetDrvLtrInfo(1) as well GetDrvLtrInfo(-1) since according to the documentation they do something. However from the documentation it is not clear to me what they do.

This however made no difference.

Greetz,

Davy
Regards,

Davy Vaessen
ICT+ Netherlands
TeraByte Support(PP)
Posts: 1506
Joined: Fri Aug 12, 2011 12:51 am

Re: gethdinfo not returning driveletters in WinPE

Post by TeraByte Support(PP) »

Where is the code where you're looking for the drive letters? I don't see anywhere in the code you posted where you're looking at the partitions. The drive letters are for the partitions, not the drives. For example: drives[0].partition[1].drvltr

The example is in this thread: https://www.terabyteunlimited.com/ucf/viewtopic.php?p=20134#p20134
Paul Purviance
TeraByte Support
nemesis
Posts: 57
Joined: Mon Jun 21, 2021 12:25 pm

Re: gethdinfo not returning driveletters in WinPE

Post by nemesis »

Hi Paul,

Yeah, it works the example as well as my original code. I indeed forgot to include the code where the drive letter is retrieved.

I think the problem might have been between the chair and the keyboard. Sorry, mate and thnx for your help!

Regards, Davy
Regards,

Davy Vaessen
ICT+ Netherlands
Post Reply