Hi Jayanthi
I did a simple program .
It worked properly on WINNT except for variables having "_" in between .If you modify the code , it will work for variables having underscore inbetween.
You just replace the string "Systemroot" with whatever variable you want .
I didn't dealt with pr.getErrorStream .It is better to include that one also in your code.
=================================================================
import java.util.*;
import java.io.*;
class testing
{
public static void main(String args[])
{
testing a= new testing();
String check = new String("Systemroot");
int varlen = check.length();
String os = System.getProperty("os.name");
System.out.println(os);
String sendcommand="";
if( os.equals( "Windows NT" ) )
{
sendcommand = "cmd.exe /c set";
}
else
if(os.equals( "Windows 95" ) )
{
sendcommand = "command.com /c set";
}
Runtime r=Runtime.getRuntime();
try
{
Process pr = r.exec(sendcommand);
InputStream stdinp = pr.getInputStream();
InputStreamReader isrinp = new InputStreamReader(stdinp);
BufferedReader brinp = new BufferedReader(isrinp);
String lineinp = null;
while ( (lineinp = brinp.readLine()) != null)
{
if((lineinp.substring(0,varlen)).equalsIgnoreCase(check))
{
System.out.println(lineinp.substring(varlen+1));
}
}
}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
}
}
================================================================
If you are willing to supply the variable along with the "java"
command , see the reply that I gave for the posting
http://www.javaranch.com/ubb/Forum34/HTML/000558.html Even now if it won't solve your problem , just post your code.