From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80439 invoked by alias); 7 Aug 2019 11:19:55 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 80432 invoked by uid 89); 7 Aug 2019 11:19:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-104.2 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1869, letter, device X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Aug 2019 11:19:54 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M5g68-1hwxbe214k-007AN7; Wed, 07 Aug 2019 13:19:44 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id D1F2FA806B8; Wed, 7 Aug 2019 13:19:43 +0200 (CEST) Date: Wed, 07 Aug 2019 11:19:00 -0000 From: Corinna Vinschen To: Michael Haubenwallner Cc: cygwin@cygwin.com Subject: Re: How to query the value of %SystemDrive% in an empty environment? Message-ID: <20190807111943.GC11632@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: Michael Haubenwallner , cygwin@cygwin.com References: <089bb243-1dbb-048a-39aa-f54048a39e26@ssi-schaefer.com> <0f9d219c-a9ae-237a-afcf-9dcc5a13bc01@SystematicSw.ab.ca> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zOr5JpMIiGv/Oaxu" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-SW-Source: 2019-08/txt/msg00101.txt.bz2 --zOr5JpMIiGv/Oaxu Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1853 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 WIND= IR > >> environment variables are preserved (or recreated): > >> $ /usr/bin/env -i /usr/bin/env > >> SYSTEMROOT=3DC:\Windows > >> WINDIR=3DC:\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 "System= Drive" > >> environment variable. > >> The problem behind is that I'm using "vswhere.exe" to locate some Visu= al Studio > >> environment from within some scripts run via 'env -i', causing vswhere= .exe to > >> create a directory named "%SystemDrive%" in the current working direct= ory: > >> So I better ensure the SystemDrive environment variable is set for vsw= here.exe. > >> Any ideas? > >=20 > > There is a reg entry: > >=20 > > $ head > > /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Syst= emBootDevice; > > echo > > multi(0)disk(0)rdisk(1)partition(3) > >=20 > > but how do you convert that to a device letter? > >=20 > > SYSTEMDRIVE is a dynamic env var created at startup pointing to the boo= t drive > > letter. It is not instantiated anywhere else as far I could find. A num= ber of > > low level reg entries use that env var. Only option is to pass it throu= gh: >=20 > Heck, even CreateEnvironmentBlock() relies on SYSTEMROOT env var being se= t, > otherwise returning things like ProgramData=3D"%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 --=20 Corinna Vinschen Cygwin Maintainer --zOr5JpMIiGv/Oaxu Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl1Ks88ACgkQ9TYGna5E T6AIkA/+LzyMXZDrPvSjZy6NiQQRQI+ceRApUfOY5ZWqTc7vkTGTnpF7iPJX3c23 Ip9rs+6G/r1GsgkhxHXE/mEw36wqxguJgHomftO2s54ItX+iOfRUrOwgnU7p3Dls ERpn8ctZSUp8jfCZloQ7RyOqcsBY+5tT9Ty9kygHYh4MLFPB5IyF9rjTpG3aQl61 UfnW+kqkYKcr17dFOc0Va3mbToh0kYVJ7ev0DfvA1kDs1nDMfZA5FrBDLXPF8KAz xocw1sYA/5Fs+mTByvhR6ZGZeNxqZXKK8hCDAEacHogv3OXkJ10zdM00EcadhgSO BvQfuuujStonLuFPU6xeanKi/4C9pR2xS6+/BybEFFKxwcPw44ctC5fbav0dja9e 6RTWDXR5IR2GH0ptTeQnWd3/03vbjNgNHtylBoWCqQ/CVXnF2Fy3RuAQek0+FWQr lWgfQGgsuOX7CngZpdmalgNxIX+V2q8cIGpaxyHRhi1MkKWHoedeSLD/ZJam2T0p ofvT0eOHDPetjN9WwHggOx9r0OuVThtAYtRvNdZTNPxIJ/K0hPuY/Hl/iQ0k5qg2 6gqZR28msXXPF5CFSInZWptscbjLxMmkzm/5bxUCV41f48/dyr7/KrYSIqAc2PN8 V/brRPnL+GW7xpdDAa+56SxPuggct1+3n/Zk2bdwPKzNmItFh08= =VNZy -----END PGP SIGNATURE----- --zOr5JpMIiGv/Oaxu--