Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Message-ID: <41B1A1C4.6020102@ieee.org> Date: Sat, 04 Dec 2004 11:38:44 +0000 From: Jason Pearce User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 MIME-Version: 1.0 To: Cygwin List Subject: Environment variables & system privilages Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I have two seemingly simple questions that I just can't find the answers to. Any assistance would be appreciated 1. What's the "right" way to add add environment variables into the user and system maps? Currently I am using regtool to manipulate the registry. For instance to set an environment variable FOO=BAR I do: regtool set -s '\HKEY_CURRENT_USER\Environment\FOO' 'BAR' or regtool set -s 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\FOO' 'BAR' The first form places it in the user's map, the second in the system map. But will this work across patform? Is there a more preferred method? 2. How can I test whether my script is running with system privilages? ie I want to write a script that installs a mount and sets and environment variable. If the script is running with system privilages I want to make the change system wide. Otherwise, in the user's profile. #!/bin/sh if [ ??????? ] then # Sytem wide mount -tfs d:/projects /projects regtool set -s 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\FOO' 'BAR' else # User ony mount -tfu d:/projects /projects regtool set -s '\HKEY_CURRENT_USER\Environment\FOO' 'BAR' fi What do I put in place of the ?????? Thanks. Jason -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/