From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50738 invoked by alias); 7 Aug 2019 02:33:25 -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 50729 invoked by uid 89); 7 Aug 2019 02:33:25 -0000 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 Received: from smtp-out-so.shaw.ca (HELO smtp-out-so.shaw.ca) (64.59.136.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Aug 2019 02:33:23 +0000 Received: from [192.168.1.114] ([24.64.172.44]) by shaw.ca with ESMTP id vBlQhzjizIhW9vBlRhUc61; Tue, 06 Aug 2019 20:33:22 -0600 From: Brian Inglis Subject: Re: How to query the value of %SystemDrive% in an empty environment? Reply-To: Brian.Inglis@SystematicSw.ab.ca To: cygwin@cygwin.com References: <089bb243-1dbb-048a-39aa-f54048a39e26@ssi-schaefer.com> Openpgp: preference=signencrypt Message-ID: <0f9d219c-a9ae-237a-afcf-9dcc5a13bc01@SystematicSw.ab.ca> Date: Wed, 07 Aug 2019 02:33:00 -0000 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 X-SW-Source: 2019-08/txt/msg00094.txt.bz2 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