Jump to content

MountVol AutoMation


MSLx Fanboy
 Share

Recommended Posts

I've been working on this guy for about the last 2 hours, apparently the GUID listed in the registry isn't a char for char match to that required of the mountvol utility :P ...

Anyways, this will mount any volume to a specified directory, and can later unmount it (and mount another one if desired).

I wrote it for a specific directory to mount to ('C:\Test_Dir'), I do not have any plans to change it (right now), but feel free to do so if desired (probably a mere FileSelectFolder).

Mount_Volume.au3

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

I've been working on this guy for about the last 2 hours, apparently the GUID listed in the registry isn't a char for char match to that required of the mountvol utility :P ...

Anyways, this will mount any volume to a specified directory, and can later unmount it (and mount another one if desired).

I wrote it for a specific directory to mount to ('C:\Test_Dir'), I do not have any plans to change it (right now), but feel free to do so if desired (probably a mere FileSelectFolder).

Nice utility. I just might incorporate this into one of my functions..

Cheers.. :lmao:

Link to comment
Share on other sites

  • 2 years later...

I've been working on this guy for about the last 2 hours, apparently the GUID listed in the registry isn't a char for char match to that required of the mountvol utility :mellow: ...

Anyways, this will mount any volume to a specified directory, and can later unmount it (and mount another one if desired).

I wrote it for a specific directory to mount to ('C:\Test_Dir'), I do not have any plans to change it (right now), but feel free to do so if desired (probably a mere FileSelectFolder).

Hi MSLx Fanboy,

It ist probably of no relevance at all, but never the less I would like to inform you that the function "findGUID($Drive)" won't work on Windows 2000. The returned value is -for what reason ever- ""\DosDevices\" & $Drive". Here a working version:

Func FindGUID($Drive)
    Local Const $DevList = "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
    Local $i=1
    Do
        If RegRead($DevList, "\DosDevices\" & $Drive) = RegRead($DevList, RegEnumVal($DevList, $i)) Then 
            $s_ReturnValue = StringReplace(RegEnumVal($DevList, $i), "\??\", "\\?\", 1) & "\"
            If $s_ReturnValue <> "\DosDevices\" & $Drive Then Return $s_ReturnValue
        EndIf
        $i += 1
    Until $i = 0
EndFunc

Regards,

Chris

EDIT: $s_ReturnValue = StringReplace(RegEnumVal($DevList, $i), "\??\", "\\?\", 1) & "\" (I'm very sorry - Copy'n'Paste!)

Edited by cherdeg
Link to comment
Share on other sites

  • 3 years later...

So the way this works is...

The MountedDevices registry key contains subkeys with values. There are subkeys named for the GUIDs of volumes, and there are subkeys named for the DOS drive letter of a volume. In either case the subkey value will be some hex number that references the actual volume. Typically this means that there are two entries for every volume, one entry with the GUID, and one with the DOS letter.

So, to find a GUID from a DOS drive letter, you have to check each subkey for the hex number. If you get a hit, you have to make sure you aren't just re-discovering the DOS letter again, and then you have to form the string to return.

Chris, you put the & "\" in the wrong place. Also, AutoIt for some reason doesn't seem to accept "+=" syntax anymore. So a better FindGUID function is....

Func FindGUID($Drive)
    Local Const $DevList = "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
    Local $i=1
    Do
        If RegRead($DevList, "\DosDevices\" & $Drive) = RegRead($DevList, RegEnumVal($DevList, $i)) Then
            $s_ReturnValue = StringReplace(RegEnumVal($DevList, $i), "\??\", "\\?\", 1)
            If $s_ReturnValue <> "\DosDevices\" & $Drive Then Return $s_ReturnValue  & "\"
        EndIf
        $i = $i + 1
    Until $i = 0
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...