Setting widows environment variable like "path "

I want to set a new value for windows environment variable path. Is there any way to set change the varibale.

You could also use ORA_FFI package to call Windows API function SetEnvironmentVariable. There is an example below.
See also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setenvironmentvariable.asp
kernel_lhandle Ora_Ffi.Libhandletype;
GetEnvironmentVariable_fhandle Ora_Ffi.Funchandletype;
SetEnvironmentVariable_fhandle Ora_Ffi.Funchandletype;
FUNCTION ff_GetEnvironmentVariable(
fhandle Ora_Ffi.funchandletype,
lpName varchar2,     -- address of environment variable name
lpBuffer varchar2,     -- address of buffer for variable value
nSize      pls_integer -- size of buffer, in characters
) RETURN pls_integer;
PRAGMA interface( C, ff_GetEnvironmentVariable, 11265 );
FUNCTION ff_SetEnvironmentVariable(
fhandle Ora_Ffi.funchandletype,
lpName varchar2,     -- address of environment variable name
lpValue varchar2     -- address of variable value
) RETURN pls_integer;
PRAGMA interface( C, ff_SetEnvironmentVariable, 11265 );
function SetEnvironmentVariable(lpName varchar2, lpValue varchar2) return pls_integer IS
BEGIN
return ff_SetEnvironmentVariable( SetEnvironmentVariable_fhandle, lpName, lpValue );
END;
function GetEnvironmentVariable(
lpName varchar2
) return varchar2 as
lpBuffer char(2000);     -- address of buffer for variable value
nSize      pls_integer; -- size of buffer, in characters
res pls_integer;
begin
lpBuffer:='*';
nSize:=2000-1;
res:=ff_GetEnvironmentVariable(
GetEnvironmentVariable_fhandle,
lpName,
lpBuffer,
nSize );
if res>0 then
return substr( lpBuffer, 1, res );
else
return null;
end if;
end;
-- Initialization
/* Load the library */
kernel_lhandle:=Ora_Ffi.Load_library
( '', 'kernel32.dll' );
/* GetEnvironmentVariable */
GetEnvironmentVariable_fhandle:=Ora_Ffi.Register_Function
( kernel_lhandle, 'GetEnvironmentVariableA', Ora_Ffi.C_Std );
Ora_Ffi.Register_Parameter
( GetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
Ora_Ffi.Register_Parameter
( GetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
Ora_Ffi.Register_Parameter
( GetEnvironmentVariable_fhandle, Ora_Ffi.C_INT );
Ora_Ffi.Register_Return
( GetEnvironmentVariable_fhandle, Ora_Ffi.C_INT );
/* SetEnvironmentVariable */
SetEnvironmentVariable_fhandle:=Ora_Ffi.Register_Function
( kernel_lhandle, 'SetEnvironmentVariableA', Ora_Ffi.C_Std );
Ora_Ffi.Register_Parameter
( SetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
Ora_Ffi.Register_Parameter
( SetEnvironmentVariable_fhandle, Ora_Ffi.C_CHAR_PTR );
Ora_Ffi.Register_Return
( SetEnvironmentVariable_fhandle, Ora_Ffi.C_INT );
To change the variable PATH you could use something like the following code:
s:=dll_path||';'||WIN32.GetEnvironmentVariable( 'PATH' );
res:=WIN32.SetEnvironmentVariable( 'PATH', s );

Similar Messages

  • Environment variables like classpath,JAVA_HOME,path

    Sir,
    I work as a java developer in a software company.I had more problems when executing servlets."could not create the java vitual machine" error comes when i try to compile java servlet file.also I do not know that how to set environment variables like classpath,path and JAVA_HOME.Also I want to know them with proper examples.
    Thanking you.
    KRamesh

    Hi Teches
    I am facing few problem in starting eclipse 3.0 ; I had gone trogh forum , 1 of the persone suggest me to upgrade the java version.For this
    I had installed java 1.5 and set the following variable
    JAVA_HOME ---> to the home dir of JAVA
    PATH ---><home dir>/bin
    CLASSPATH --><jre>/lib
    But when ever i m giving "java -version" command on console , the result is as follows:
    C:\>java -version
    java version "1.3.1_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
    Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
    suggestion are welcome Plz.
    ;

  • Set DISPLAY environment variable -- in DBCA not working at AIX OS

    Hi,
    I want to create new database in AIX OS and database is oracle 10g:-
    When i say DBCA it is giving below error, what should i do?
    $ dbca
    DISPLAY not set.
    Set DISPLAY environment variable, then re-run.
    Please help...

    Pravin wrote:
    How to set the DISPLAY environment variable in AIX?Usual format is:
    +<host>:<display-number>+
    E.g.
    export DISPLAY=192.168.0.235:1
    Where the host is the hostname or IP address of the client platform running a X-Server. If the X-Server is running locally, then this entry can be omitted.
    The display-number is the display number of the X-Server to use. A single X-Server can have multiple displays. E.g. Unix server running a X-Server can have 10 users connected via X-Terminals and will this have 10 displays.
    Judging from X-Windows questions asked on OTN, it seems to be a tad complex to grasp for some - especially those from a MS Windows background as X-Windows is very different and also reverses the client-server concept, requiring the X-Server component to be running on the client platform (where the server platform runs the program that is the X-client).
    So it is a lot easier to rather use something like VNC instead - supported on most Unix platforms, Linux, Windows and Apple's OS/X.
    Simply run the VNC server on the server platform to create a virtual container for running the X-server display. Connect from a client using a VNC client.
    As it uses the RFB (Remote Frame Buffer) protocol, it is a lot faster than running the slower and larger X11 protocol required for X-Windows connectivity over TCP/IP.

  • Why do we actuallya need the setting of environment variables?

    Hello guys,
    I read that, in order to connect to the database via SQL*Plus, we need to have the environment variables set. So, SQL*Plus is a command tool, which doesnt know over which path to connect to db, if the environment variables are not set?
    How about the needs of setting environment variables at point of view of MS-DOS? I know that over MS-DOS we can check if the environment variables are already set or not. Or we can actively set the environment variables.
    When should we actually set the environment variables? Before we run the GUI or after? I read, that if we set it before we run the GUI, then the setting will be taken over when it comes to that step by running GUI. I am curious, since this would be interesting to know, if we use other version than XE.
    Thanks..

    Oracle's flexibility ... many different versions working the same on many different versions of many different operating systems ... means that a single consistent installation and configuration methodology must work everywhere so as not to have the limitations of other competing products that work on only a single operating system or require that one learn a different syntax and methods for different versions.
    Be grateful Oracle is as it is. Your competence in one version and operating system translates into competence in others.

  • How to set ORACLE_HOME environment variables in win 2003

    Can anyone tell me how to set ORACLE_HOME environment variables in Win2003
    Please tell me the significance of that also.It will be really helpful if u can help me out from Path variable seting of JAVA SDK also... Thanks in advance...

    hi
    use this code IN FORMS60 variable in Regedit
    \\server\DATA\store\Forms;
    Rizwan

  • Setting the environment variable

    I just installed the rpm for the 1.4 SDK on my RedHat 7.1 box. Does anyone know how I can set the environment variable so it will recognize Java from the command line? Thanks in advance.

    You need to set a couple of environment variables in your "profile" script. Which one, exactly, depends on the shell you use. It's probably .profile on your home directory.
    Try
    JAVA_HOME=/usr/java1.4 (or wherever it really is)
    PATH=$PATH:$JAVA_HOME/bin
    export JAVA_HOME,PATH

  • Setting new environment variable on Linux

    {noformat}I need to set new environment variable on my linux machine from inside my code. I am using csh and the command works fine from command line:
    setenv IFConfigLocation4 /home/username/myfile.xml
    But when i try the same thing from Java code it does not seem to have any effect. here is my code:
    import java.util.*;
    import java.io.*;
    public class CDE_parser_methods{
    public static String fileParse(String inFile, String parserName, String outFile, String CMConfig_locale)
    String parsed = "SUCCESSFUL";
    System.out.println("Parsing file..." + "\nParser name: " + parserName +"\nInput file name: " + inFile + "\nOutput file name: " + outFile + "\nCMConfig file is: " + CMConfig_locale);
    System.out.println("Current Java version: " + System.getProperty("java.version"));
    try
              String cmd[]={"/bin/csh", "-c", "setenv IFConfigLocation4 " + CMConfig_locale};
              Process proc = Runtime.getRuntime().exec(cmd);
              int exitVal= proc.waitFor();
              System.out.println("Value of setenv command is: " + exitVal);
              String cmd2[]={"/bin/csh", "-c", "env"};
              Process proc2 = Runtime.getRuntime().exec(cmd2);
              InputStream instr = proc2.getInputStream();
              InputStreamReader inread = new InputStreamReader(instr);
              BufferedReader buf = new BufferedReader(inread);
              String line=null;
              while((line=buf.readLine()) != null)
                   System.out.println(line);
              int exitVal2= proc2.waitFor();
              }catch(CMException cme){
                   System.out.println("Issue when trying to executing parse command, details: " + cme.getMessage());
                   System.out.println("Description of the issue is: " + cme.getDescription());
                   parsed = "FAILURE: " + cme.getDescription();
              }catch(Exception e){
                   System.out.println("Uncought exception, details: " + e.getMessage());
                   parsed = "FAILURE: " + e.getMessage();
         return parsed;
    public static void main(String[] args) {
         String results=CDE_parser_methods.fileParse("/opt/itemfield/ServiceDB/Project2/Mapping_for_Account_Number_Structure_ITS_Input_File.xls","MappingforAccountNumberStructure","/opt/itemfield/ServiceDB/Project2/test_ws_44.xml","/home/rvenishe/CMConfig.xml");
         System.out.println("Result of fileParse call is: " + results);
         }The out put of my env command does NOT contain system variable "IFConfigLocation4". Any ideas? {noformat}

    Environment variables and their values set from within a user process has their scope and lifetime limited to the process and its subprocesses. See java.lang.ProcessBuilder class and its API documentation for setting env for a subprocess that will be started by a ProcessBuilder instance. Even in the C programming we have the same limitation for the environment.
    Since they are not globally set, system command like env or Java method like System.getenv() can't see them.

  • Setting Oracle environment variable using batch (.bat) file in windows

    Hi,
    Oracle 9i db
    Windows OS
    I am in process to create the database (Considered that Oracle9i software is already installed) by running one batch file which consist of all the scripts for the database creation.
    But i also want to set the environment variables at MyComputer(right click)>properties>advance>environment, permenently by running the batch (.bat) file
    ORACLE_HOME
    ORACLE_BASE
    ORACLE_SID
    So, how can it be done ?
    With Regards

    Hi,
    *@echo off*
    set ORACLE_SID=iprsdb
    set ORACLE_BASE=C:\oracle
    set ORACLE_HOME=C:\oracle\ora92     
    call C:\install_bkp\test_env_var.bat
    echo Test Successfull.
    Above mentioned is the code written in the batch (.bat) file
    In that i have also called another .bat file which test the env. variable values which is as below:
    c:\>test_env.bat
    ===================
    Testing oracle sid
    ===================
    iprsdb
    =====================
    Testing oracle base
    ===================
    C:\oracle
    =====================
    Testing oracle home
    =====================
    C:\oracle\ora92
    Test Successfull.
    But when i checked at MyComputer(right click)>properties>advance>environment variables
    there, I saw none of the entries from the above, why so ?
    how to set env. variables permanently using the DOS commands. ?
    With Regards

  • Setting Linux environment variable

    Is there other web site which talks about how to set the environment variable of J2EE for Linux?
    I followed this web site
    http://www.dougsparling.com/comp/howto/linux_java.html
    but after all
    when I tired to compile a servlet program... it couldn't be complied. I think the case is that the compiler couldn't find servlet.jar ...
    why is that?

    You have to verify that your CLASSPATH environment variable is set in your account's profile. I use the
    bash shell therefore my variables are set in .bashrc
    for example my CLASSPATH is set to :
    CLASSPATH=.:$J2EE_HOME/lib/j2ee.jar:$J2EE_HOME/lib/locale

  • Is there any way to get windows environment variables like %USERNAME% with javascript?

    is there any way to get windows environment variables like %USERNAME% with javascript using Adobe 10 pro?

    There is a fair amount of Acrobat JavaScript and Acrobat knowledge need to sort all of this out.
    The identity object holds a lot of sedative information. First, upon installation of Acrobat, only the login name is available in the identity object and the end user of the application needs to complete the "Name", "email" and "Organization Name" in the application's preferences. These are the only fields that are available to Acrobat JavaScript identity object as corporation, email, loginName, and name.
    Using the instructions in The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript) you can run the following script in the JS console to see the items of the identity object:
    for(i in identity) {
    console.println(i +": " + identity[i]);
    and the following will appear in the console:
    loginName: georgeK
    name: George Kaiser
    corporation: Example
    email: [email protected]
    true
    The documentation states you need to use a trusted function to access this data, but you can access it at startup of Acrobat/Reader and add the properties of the identity object to an array:
    // application variable to hold the properties of the identity object
    var MyIdentity = new Array();
    // loop through the properties of the identity object
    for (i in identity) {
    // place each property of the identity object into an element of the same name in the Identity array
    MyIdentity[i] = identity[i];
    console.println(i +": " + MyIdentity[i])
    You access the items with:
    var loginUser = MyIdentity[loginName];  // get the loginName property
    In the user application level JavaScript file. See Acrobat Help / User JavaScript Changes for 10.1.1 (Acrobat | Reader) for the location of the application level folder you need to use.
    I would change the name of the array used in this post so an untrusted user cannot get to your data. Some of this data can be used in hacking into a user's system.

  • I want to set Jdeveloper environment variables

    First,thanks for your answer.But I mean to set Jdevelop
    environment variables.If I can't set right Jdeveloper
    enironment,program can't pass the compile.Because "import
    oracle.html.*" can't be found by Jdeveloper.
    null

    Hi
    You would need to include jweb.jar file as a library in your
    project properties.
    jweb.jar comes with Oracle Application Server. Copy the jar file
    to lib directory in JDeveloper and add it as a library to the
    project.
    This would make import oracle.html.* work.
    regards
    raghu
    Micheal Chang (guest) wrote:
    : First,thanks for your answer.But I mean to set Jdevelop
    : environment variables.If I can't set right Jdeveloper
    : enironment,program can't pass the compile.Because "import
    : oracle.html.*" can't be found by Jdeveloper.
    null

  • How to set the Environment Variable

    I'm going through a tutorial on how to create an application and run from the command prompt. I have finished installing my jdk 6 Upadate 5 but i don't know how to set the Environment Variable for the javac compiler and the java interpreter to find my program.
    I have created an application called "ExampleProgram" and have saved it on drive C:. How do i set the Environment Variable so that the "javac" compiler and the "java" interpreter can find it

    gyesa_say wrote:
    I'm using Windows XP Service Pack 2.A very bad choice to go with Windows. Personally I prefer Linux.
    I Google and had several information on how set it, but i tried all of them and none seem to work.I typed "how to set environmental variable in winxp" in Google and the very first link provided all the information I needed (you need). These things will make much more sense if you go through it yourself rather than having someone else spoon-fed you the answer.

  • Best way to set global environment variables?

    What is the best way to set global (i.e. for all users of the computer, ideally all shells as well) environment variables under Leopard?
    I know that they can be set via ~/.bashrc, ~/.profile or in my case ~/.zshrc files in the terminal on a per user basis.
    Also, they can be set for GUI apps as well via ~/.MacOSX/environment.plist on a per user basis.
    http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Artic les/EnvironmentVars.html
    The path can apparently be set globally by adding files to /etc/paths.d/*
    http://blog.plotdevice.org/2008/04/global-path-in-mac-os-x-leopard/
    Is there a way to set environment variables globally so that they are accessible to all users and all programs including nonstandard shells like zsh?
    My inclination is to set them in /etc/rc.common but that seems like it might be a bad idea. I'd prefer something more like the /etc/paths.d/* solution that only involves adding files, not modifying existing ones. They should be less likely to be overwritten in a system update later.

    They may be less likely to be overwritten than you fear. A lot of things depend on modifications to the system scripts like /etc/profile. Although I'd expect these to be broken by an upgrade to Leopard, for example, they have survived all Tiger upgrades on my machine. You could always have them source scripts in /usr/local, say, so that the work involved in reconfiguring them if they are overwritten is minimal. (Or you could just install your versions in /usr/local and make the system scripts symlinks to those versions - if anything is overwritten, it would be the symlink rather than the file itself. An automated start up script could even check and recreate the symlink if necessary.)
    - cfr

  • Trouble Setting Windows Environment Variables

    My environment:
    Windows XP Professional
    Intellij 6.0.4
    JDK 1.4.
    I am seeing some very weird behavior when I try to get/set Environment Variables in Windows XP. I use the following code to read the variables:
    Process p = r.exec( "cmd.exe /c set" ); I create an environment varialbe through the Windows control panel, and it does not show up when I execute the above command. However, when I close my IDE and reopen it and run the same code, the variable appears. How is this possible? I am using the Windows XP cmd.exe in my program to read the variables. When I open a DOS window and type the same command, my variable is there.
    This is driving me crazy.
    i want my program to do some work, but then check a system variable to see if it should continue. I want a user to be able to stop processing by setting the environmen variable to true.
    Thanks!
    Nathan

    Runtime.exec has a lot of overloadings. Two of them
    allows you to specify the environment variables.
    exec
    public Process exec(String[] cmdarray,
    String[] envp,
    File dir)
    throws IOExceptionExecutes the specified command and
    arguments in a separate process with the specified
    environment and working directory.
    cmdarray - array containing the command to call and
    its arguments.
    envp - array of strings, each element of which has
    environment variable settings in format name=value.
    dir - the working directory of the subprocess, or null
    if the subprocess should inherit the working directory
    of the current process.
    I had this sample program:
    public class SetVarExample {
    public static void main (String[] args) throws Exception {
         String[] cmd_env= new String[] {"password="+"ABCD","Path=C:\\Sun\\AppServer\\jdk\\bin"};
         String cmd = "cmd /c SET ";
         Runtime.getRuntime().exec(cmd,cmd_env);
    System.out.println( "Finish ...." );
    I tried it in a command prompt. But looks like when the program exits, it's a whole new process and so it does not retain the env variables set in the java program.
    Any suggestions? Am I doing it worng?
    thanks

  • Setting windows environment variables from Java program

    Is there any way to set environment variables from Java program in Windows? Any help is appreciated.
    Here is my situation:
    I need to decrypt an encrypted Oracle user password in a batch file which will be used while running a sql script with sqlplus. I was planning to have bat file which will call a Java program decrypt the password and set it as an env variable in windows which will be available while calling sqlplus.
    thanks

    Runtime.exec has a lot of overloadings. Two of them
    allows you to specify the environment variables.
    exec
    public Process exec(String[] cmdarray,
    String[] envp,
    File dir)
    throws IOExceptionExecutes the specified command and
    arguments in a separate process with the specified
    environment and working directory.
    cmdarray - array containing the command to call and
    its arguments.
    envp - array of strings, each element of which has
    environment variable settings in format name=value.
    dir - the working directory of the subprocess, or null
    if the subprocess should inherit the working directory
    of the current process.
    I had this sample program:
    public class SetVarExample {
    public static void main (String[] args) throws Exception {
         String[] cmd_env= new String[] {"password="+"ABCD","Path=C:\\Sun\\AppServer\\jdk\\bin"};
         String cmd = "cmd /c SET ";
         Runtime.getRuntime().exec(cmd,cmd_env);
    System.out.println( "Finish ...." );
    I tried it in a command prompt. But looks like when the program exits, it's a whole new process and so it does not retain the env variables set in the java program.
    Any suggestions? Am I doing it worng?
    thanks

Maybe you are looking for

  • Need help about tutorial demo file

    I dont understand the (Object) word in the 15th line of the IteratorDemo class of the tutorial J2SDK Please find above the source code. Thank for any help. //display 13 cards using iterator interface public class IteratorDemo implements java.util.Ite

  • Zen Mozaic 8GB pin

    I NEED this mp3 player... but I can see that now it'ss only available in black. When can I get one? My mp3 player broke and I can't li've very long without music, but this player is worth the wait! Please tell me that it will be available soon!

  • 9i JDeveloper UML classes

    Hello, I have installed Oracle's 9i JDeveloper release candidate 2 on my Red Hat 7.2 Linux box. I was doing the tutorials of the user's guide and when I tried to do UML classes, I got an error stating that it could not continue with the execution. I

  • Calling workbook from oracle application 11.03

    hi, i want to call one report of discoverer from oracle application 11.03 request set.if any one has done this ever or have any idea how should i do this,please reply back. thanks in anticipation null

  • Import Routes based on Multiple RT

    dear all, sorry if repost, i've tried to search but can't find the thread. currently i am trying to import routes within vrf by matching two route-target exported by other PE. is it can be done with cisco router or not. I have tried with couple way b