X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=ZiXMAREV+t5NZsQ+ fIbGebiihwqDvPWZ4W1jzW/oFr/KrEEQPtD+TfRy6J2luGt1+wWkZBq4WryfcoBv FqHAUqn/LcZAamtAHUDpRyb4IAVAGWz0COf9D9ckzPeRTAVOi1o84+WCIV10dgB/ ZdDVB6djZkROniWcTIMU7k5DAwM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=ZnuOy9V24i19nj+YnigOmv M75NI=; b=qyNNiY6EXXezS0VICpVbK1Li8vgZ5SNHShi+V6ulSwZwSYrpVKbclD B9wpUYmsLilQFb14Ax8bmY2WPKeI/FjxF9y/KJdd4af0q/qs3VNvI3vdbrXCpX3b mt0mHNkiCDLza/EcRWI+i95BeSU+y81rEfkitkoUIq8M7orIqUmac= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1797, letter, device X-HELO: atfriesa01.ssi-schaefer.com Subject: Re: How to query the value of %SystemDrive% in an empty environment? To: cygwin AT cygwin DOT com References: <089bb243-1dbb-048a-39aa-f54048a39e26 AT ssi-schaefer DOT com> <0f9d219c-a9ae-237a-afcf-9dcc5a13bc01 AT SystematicSw DOT ab DOT ca> From: Michael Haubenwallner Openpgp: preference=signencrypt Message-ID: Date: Wed, 7 Aug 2019 13:08:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <0f9d219c-a9ae-237a-afcf-9dcc5a13bc01@SystematicSw.ab.ca> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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". > > $ /usr/bin/env -i SYSTEMDRIVE="$SYSTEMDRIVE" /usr/bin/env > SYSTEMDRIVE=C: > SYSTEMROOT=C:\WINDOWS > WINDIR=C:\WINDOWS Feels like the Cygwin DLL better should try to keep SYSTEMDRIVE being set, no? /haubi/ (about to prepare some patch) -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple