Getting Windows "MACHINE SID" without fork() & exec()?
René Berber
rene.berber@gmail.com
Thu Apr 23 19:27:48 GMT 2026
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.)
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
Hope this helps.
--
R.B.
More information about the Cygwin
mailing list