Environment variables & system privilages

Jason Pearce jason.pearce@ieee.org
Sat Dec 4 11:39:00 GMT 2004


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/



More information about the Cygwin mailing list