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:from:subject:reply-to:to:references:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=HjbSe1EJAchq5AxD VWNqPDNJr75Ozf/zFbFTYW2fMqKiTg4GzVmiaaEvumdZs/xlYYBapUwjI6YM56h5 wEuoXE4L8CgEqpBcCPklb4YYeLrGlBcdWabPRWejxTITrdX+JVKXigN0+CVricsS QHB4YWYMqmn4UBMo+SO+uJvkMKg= 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:from:subject:reply-to:to:references:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=fy/CBvOXMj97X3RT1tuzl6 8NBJA=; b=f8Dp3a5PG1cURM8cP4OB2IIfSXksSVkTKpzRpq5iRRWIW4nadp3s7Z 4w3PHF1byjsO4rOjXyx/rnm+H4vnUkGMgNV/HjfTjehJ3jyjksOfwtuh/U++M/Mg WQsM+TtSiHZR12M+Y9HqjdDtC/132PPCNjSEJb7vnqBiSEy2DLvVQ= 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=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=letter, device X-HELO: smtp-out-so.shaw.ca From: Brian Inglis Subject: Re: How to query the value of %SystemDrive% in an empty environment? Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca To: cygwin AT cygwin DOT com References: <089bb243-1dbb-048a-39aa-f54048a39e26 AT ssi-schaefer DOT com> Openpgp: preference=signencrypt Message-ID: <0f9d219c-a9ae-237a-afcf-9dcc5a13bc01@SystematicSw.ab.ca> Date: Tue, 6 Aug 2019 20:33:20 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <089bb243-1dbb-048a-39aa-f54048a39e26@ssi-schaefer.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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: $ /usr/bin/env -i SYSTEMDRIVE="$SYSTEMDRIVE" /usr/bin/env SYSTEMDRIVE=C: SYSTEMROOT=C:\WINDOWS WINDIR=C:\WINDOWS -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. -- 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