This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to query the value of %SystemDrive% in an empty environment?

On Aug  7 13:08, Michael Haubenwallner wrote:
> On 8/7/19 4:33 AM, Brian Inglis wrote:
> > On 2019-08-06 09:20, Michael Haubenwallner wrote:
> >> using 'env -i' to create an empty environment, the SYSTEMROOT and WINDIR
> >> environment variables are preserved (or recreated):
> >>  $ /usr/bin/env -i /usr/bin/env
> >>  SYSTEMROOT=C:\Windows
> >>  WINDIR=C:\Windows
> >> And with cygpath, there is the -A, -D, -H, -O, -P, -S, -W and even -F flags
> >> to query the values for various directories.
> >> Now what I've failed to find is how to query the value for the "SystemDrive"
> >> environment variable.
> >> The problem behind is that I'm using "vswhere.exe" to locate some Visual Studio
> >> environment from within some scripts run via 'env -i', causing vswhere.exe to
> >> create a directory named "%SystemDrive%" in the current working directory:
> >> So I better ensure the SystemDrive environment variable is set for vswhere.exe.
> >> Any ideas?
> > 
> > There is a reg entry:
> > 
> > $ head
> > /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/SystemBootDevice;
> > echo
> > multi(0)disk(0)rdisk(1)partition(3)
> > 
> > but how do you convert that to a device letter?
> > 
> > SYSTEMDRIVE is a dynamic env var created at startup pointing to the boot drive
> > letter. It is not instantiated anywhere else as far I could find. A number of
> > low level reg entries use that env var. Only option is to pass it through:
> Heck, even CreateEnvironmentBlock() relies on SYSTEMROOT env var being set,
> otherwise returning things like ProgramData="%SystemDrive%\ProgramData".

So, what does this have to do with Cygwin in case you clean out the
environment?  This is nothing you want to do if you plan to start
a non-Cygwin executable.


Corinna Vinschen
Cygwin Maintainer

Attachment: signature.asc
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]