Re: Environment variables & system privilages
>> >> 1. What's the "right" way to add add environment variables into the user >> and system maps? > >Well, that's probably the best you could hope for, if you want system-wide >settings. I'm not aware of any other command-line tool that would set >these. If you only want to set environment variables for Cygwin shells, >you might want to edit /cygwin.bat instead. > there is a command line tool from the w2k ressource tools named SETX.EXE doing a google search reveals the links to ms homepage. It is supposed to set environment variables for local user and/or local machine from command line. you might give it a try benjamin -- 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/
Re: Environment variables & system privilages
On Mon, 6 Dec 2004, Brian Dessent wrote: > Jason Pearce wrote: > > > Thanks. This works well enough. But I take it there is no universal > > command to check for system permissions. > > The procedure is just try a command that needs system privilages and > > watch the exit status. > > Well, if you really want to check for this you could try comparing the > output of "id -u" to 18, the UID of the SYSTEM account. I don't know if > the system account's id varies across different versions (eg 98 vs. > 2k3), though. > > Brian AFAIU, those aren't the "system privileges" that Jason meant -- I think he just wanted to test whether his user has permission to write to the HKLM registry tree. The best way to test that is to try actually writing something (which is exactly what "mount" does). Also, there is no SYSTEM account on 9x. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_[EMAIL PROTECTED] ZZZzz /,`.-'`'-. ;-;;,_[EMAIL PROTECTED] |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "The Sun will pass between the Earth and the Moon tonight for a total Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT -- 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/
Re: Environment variables & system privilages
Jason Pearce wrote: > > Thanks. This works well enough. But I take it there is no universal > command to check for system permissions. > The procedure is just try a command that needs system privilages and > watch the exit status. Well, if you really want to check for this you could try comparing the output of "id -u" to 18, the UID of the SYSTEM account. I don't know if the system account's id varies across different versions (eg 98 vs. 2k3), though. Brian -- 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/
Re: Environment variables & system privilages
Thanks. This works well enough. But I take it there is no universal command to check for system permissions. The procedure is just try a command that needs system privilages and watch the exit status. Also for the benefit of anyone reading this thread - there was an error in my original post. I dropped the "Environment" key from the registry path for setting system environment variables. It should have read. regtool set -s 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\FOO' 'BAR' Jason Igor Pechtchanski wrote: On Sat, 4 Dec 2004, Jason Pearce wrote: 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? Well, that's probably the best you could hope for, if you want system-wide settings. I'm not aware of any other command-line tool that would set these. If you only want to set environment variables for Cygwin shells, you might want to edit /cygwin.bat instead. 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. Why not try mounting with system privileges first? 'mount' will fail if it's unable to set mounts, and you can fall back on user mounts. In other words: #!/bin/sh if mount -tfs d:/projects /projects; then 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 #!/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 ?? HTH, Igor -- 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/
Re: Environment variables & system privilages
On Sat, 4 Dec 2004, Jason Pearce wrote: > 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? Well, that's probably the best you could hope for, if you want system-wide settings. I'm not aware of any other command-line tool that would set these. If you only want to set environment variables for Cygwin shells, you might want to edit /cygwin.bat instead. > 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. Why not try mounting with system privileges first? 'mount' will fail if it's unable to set mounts, and you can fall back on user mounts. In other words: #!/bin/sh if mount -tfs d:/projects /projects; then 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 > #!/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 ?? HTH, Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_[EMAIL PROTECTED] ZZZzz /,`.-'`'-. ;-;;,_[EMAIL PROTECTED] |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "The Sun will pass between the Earth and the Moon tonight for a total Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT -- 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/
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/