Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Environment Variables

Options
  • 19-06-2002 2:45pm
    #1
    Closed Accounts Posts: 536 ✭✭✭


    I'm not really sure where this belongs.

    Anyway I'm creating an installation package and I need to be able to set environment variables.
    I can execute batch files from the package.


    So what I wondering is there anyway that I can set env variables from dos promt?

    I know I can type 'set JAVA_HOME=c:\jdk' but that path is only valid for that dos session so that won't do :(

    I need to be able to set it permanently.


Comments

  • Closed Accounts Posts: 76 ✭✭photty


    i think you will need to edit the users autoexec.bat and add the new variables in there. Just tack the new variable setting onto the end of the file


  • Closed Accounts Posts: 536 ✭✭✭flyz


    Originally posted by photty
    i think you will need to edit the users autoexec.bat and add the new variables in there. Just tack the new variable setting onto the end of the file

    that won't work cos 95/98 are the only two microsoft operating systems that use the autoexec.bat

    NT and 2k dont :(


  • Registered Users Posts: 1,994 ✭✭✭lynchie


    In win2k, all environment variables are stored in the registry. To add an environment variable for the current logged on user add it to

    HKEY_CURRENT_USER\Environment

    and for system variables, i.e. ones that are set for all users

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

    This is the same for winxp AFAIK.

    If you are trying to do this via java, you may have to write a DLL to do the registry entries and then use JNI to call it from Java


  • Closed Accounts Posts: 536 ✭✭✭flyz


    Originally posted by lynchie
    In win2k, all environment variables are stored in the registry. To add an environment variable for the current logged on user add it to

    HKEY_CURRENT_USER\Environment

    and for system variables, i.e. ones that are set for all users

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

    This is the same for winxp AFAIK.

    I can't modify registry entries from the installation package either :) I can read them alright but not write to them.
    What I've being trying to do so far is edit the autoexec.nt/config.nt files in the system32 directory. Haven't gotten that working yet. However this will need a reboot to take affect too :(

    BTW I'm using is InstallAnywhere 5 Standard by Zerog.

    If you are trying to do this via java, you may have to write a DLL to do the registry entries and then use JNI to call it from Java

    I'll prolly try that approach next, I'll be able to launch an external java application from the installation. It's just finding the time to write the dll is the problem :(


  • Registered Users Posts: 1,994 ✭✭✭lynchie


    Why can't you modify registry settings? This would be the easiest and most straightforward approach. Is it because you dont have security permissions to write to the registry? If so, im not sure if you'll be able to do what you want.

    I have just added the line SET LYNCHIE=1 to my autoexec.nt on win2k. If I run cmd.exe and type set I don't see my environment variable. If I run command.com (which is the MS-DOS interpreter) and type set, I do see my environment variable. Have you tried accessing the environment variable from command.com instead of cmd.exe


  • Advertisement
  • Closed Accounts Posts: 536 ✭✭✭flyz


    Originally posted by lynchie
    Why can't you modify registry settings? This would be the easiest and most straightforward approach. Is it because you dont have security permissions to write to the registry? If so, im not sure if you'll be able to do what you want.
    Sorry I should have made myself a bit clearer I suppose.

    What I'm trying to do is create an installation package for my software that is as user friendly as possible.
    that is set environmnet variables and edit any configuration files that are needed.
    These tasks need to be automated by the installer package.
    The application is a servlet and needs jdk and tomcat to be installed so I install those applications and set the env variables JAVA_HOME and CATALINA_HOME if they're not already there.

    I have just added the line SET LYNCHIE=1 to my autoexec.nt on win2k. If I run cmd.exe and type set I don't see my environment variable. If I run command.com (which is the MS-DOS interpreter) and type set, I do see my environment variable. Have you tried accessing the environment variable from command.com instead of cmd.exe

    Nope

    Have you tried accessing the environment variable from system properties?
    that's what I've been testing mine from.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Add the information you want to your own registry.
    Export your settings "tree" in the registry as a .reg file.
    Open in notepad, and edit it so it only contains the "new" settings you want to take effect.

    *execute* the .reg file from within your setup program (or call a batch file which does it for you).

    This will update your registry.

    jc


  • Closed Accounts Posts: 536 ✭✭✭flyz


    Originally posted by bonkey
    Add the information you want to your own registry.
    Export your settings "tree" in the registry as a .reg file.
    Open in notepad, and edit it so it only contains the "new" settings you want to take effect.

    *execute* the .reg file from within your setup program (or call a batch file which does it for you).

    This will update your registry.

    jc

    perfect! thanks Bonkey :D


Advertisement