Re: Getting Windows "MACHINE SID" without fork() & exec()?

Brian Inglis via Cygwin <[email protected]> Thu, 23 Apr 2026 16:55:53 -0600
Newsgroups gmane.os.cygwin
Organization Systematic Software
Message-ID <[email protected]>
On 2026-04-23 13:27, René Berber via Cygwin wrote:
> On 4/23/2026 11:07 AM, Takeshi Nishimura via Cygwin wrote:
> 
>> Does Cygwin have a secret shell variable or /proc file which contains
>> the current machine's MACHINE SID, without having to resort to calling
>> an external program (no fork(), no exec(), please)?
> 
> Create your own environment variable.  Store it once per bash session 
> with .bashrc for example, or permanently with all the other Windows variables.
> 
> Use PsGetSid to get the value into that variable (i.e. no super user access 
> needed like with regtool.)

No regtool or superuser access needed for most queries and regtool accepts paths:

$ l /proc/registry*/
/proc/registry/:
HKEY_CLASSES_ROOT/  HKEY_CURRENT_CONFIG/  HKEY_CURRENT_USER/ 
HKEY_LOCAL_MACHINE/  HKEY_PERFORMANCE_DATA/  HKEY_USERS/

/proc/registry32/:
HKEY_CLASSES_ROOT/  HKEY_CURRENT_CONFIG/  HKEY_CURRENT_USER/ 
HKEY_LOCAL_MACHINE/  HKEY_PERFORMANCE_DATA/  HKEY_USERS/

/proc/registry64/:
HKEY_CLASSES_ROOT/  HKEY_CURRENT_CONFIG/  HKEY_CURRENT_USER/ 
HKEY_LOCAL_MACHINE/  HKEY_PERFORMANCE_DATA/  HKEY_USERS/

> Ref: https://learn.microsoft.com/en-us/sysinternals/downloads/psgetsid
> 
> Caveat: The first time you run PsGetSid it shows a popup with the license 
> agreement.
> 
> Example:
> XPS-8930: ~
> $ /home/reneb/bin/SysinternalsSuite/PsGetsid
> 
> PsGetSid v1.44 - Translates SIDs to names and vice versa
> Copyright (C) 1999-2008 Mark Russinovich
> Sysinternals - www.sysinternals.com
> 
> SID for \\XPS-8930:
> S-1-5-21-3651791898-1415975337-2452924111
> 
> XPS-8930: ~
> $ /home/reneb/bin/SysinternalsSuite/PsGetsid |& tail -n 3
> S-1-5-21-3651791898-1415975337-2452924111

Do you mean like these values replaced by '*'?

$ regtool list -v /proc/registry/HKEY_USERS/
.DEFAULT\ ()
S-1-5-18\ ()
S-1-5-19\ ()
S-1-5-20\ ()
S-1-5-21-**********-**********-**********-1001\ ()
S-1-5-21-**********-**********-**********-1001_Classes\ ()
...

Of course, if the info is not yours, you probably will need elevated access!

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple