delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/12/04/06:39:23

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <jason DOT pearce AT ieee DOT org>
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 <cygwin AT cygwin DOT com>
Subject: Environment variables & system privilages

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019