2

In this thread How to hide drive for specific users in Windows 7? it talks about how you can hide drive letters for specific users. I am trying to follow Nathan Hinkle's answer but I am stuck. I need to find 3 hex values that I need to use for 3 different users in the registry.

I need to know the hex values that I must use for:

USER 1: Disabling Drive N, leave every other drive alone

USER 2: Disabling Drive M, leave every other drive alone

USER 3: Disabling Drive N & M, leave every other drive alone

I know this is probably very simple but I just don't understand how to get the values. So please can someone respond with the 3 hex values I need? Also if you feel like you need to do a short tutorial (for future reference) on how you got those exact values then please feel free to do so.

Please refer to the thread link above to know how I need the hex values to look.

Blackwood
  • 3,184

3 Answers3

1

Don't use the answer given here - it has incorrect hex conversion just like another top google result.

What you need to do is go here: https://ss64.com/nt/syntax-nodrives.html And if you want to convert that decimal value to hex, use this site https://www.rapidtables.com/convert/number/hex-to-decimal.html and fill in preceding zeroes if you need (like 0001823F because we needed an 8-digit hex).

Snake
  • 11
0

You can use PowerShell!

'{0:x}' -f [int]('MN'.ToCharArray() | % { 1 -shl ($_ - [char]'A') } | measure -Sum).Sum
# note:           ^^ change this to the uppercase letters of all drives you want to hide

The above example produces 3000 (for User 3). Using just M produces 1000 (for User 2); just N produces 2000 (User 1). Here's how it works:

  • .ToCharArray() splits your drive specifier string into individual characters that will move along the pipeline independently
  • % is shorthand for ForEach-Object; it allows running a chunk of code for each item on the pipeline or, in our case, transforming each item before passing it down the pipeline
  • $_ - [char]'A' subtracts the A character from the current letter character on the pipeline, calculating the bit position for one drive letter (e.g. C - A = 2)
  • 1 -shl (...) calculates the numeric value that will hide just the one current drive by placing a binary digit 1 in the appropriate bit position
  • measure -Sum collects and adds up all the numbers coming down the pipeline, combining all the individual-drive-hiding values into one number
  • [int](...).Sum gets the Sum property from the measurement results object and casts it to an integer (as opposed to a double-precision floating point number, which can't easily be formatted as hex)
  • '{0:x}' -f formats the number on the right-hand side as a hex string
Ben N
  • 42,308
0

I know this is probably very simple but I just don't understand …

I feel your pain.  I would offer my opinion that the reason why you don’t understand nhinkle’s answer to that other question is because it doesn’t exactly make any sense.  I found this explanation at Microsoft TechNet, which says, in effect:

Take this template:

  **** **ZY  XWVU TSRQ  PONM LKJI  HGFE DCBA

Write ones below the drive letters that you want to hide.  Write zeros below the *s and the drive letters that you don’t want to hide.  You should now have 32 1s and 0s.  Convert to hex.

I’ll assume that you are asking about drives N: and M:, rather than N and M.  To hide drive N:, you would have

    **** **ZY  XWVU TSRQ  PONM LKJI  HGFE DCBA
    0000 0000  0000 0000  0010 0000  0000 0000

which gives you 00002000 (i.e., 2000 hex).  By the same method, M: is 1000, and “User 3” (N: and M:) is 3000.