write to registry to set ie start page
<p>I found a code to write to the registry that looks promising, but I feel like I'm missing something.</p>

<p><a href="http://stackoverflow.com/questions/62289/read-write-to-windows-registry-using-java">java source code original post here</a></p>

<p>Registry key location.
HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN
D word "Start page"</p>

<p>I also found a bat code which didn't work for me.</p>

<pre><code>REG ADD "HKCU\SOFTWARE\MICROSOFT\INTERNET EXPLORER\MAIN" /V "START PAGE" /D "http://www.yahoo.com/" /F
</code></pre>

<p>When I try to run this nothing happens.</p>

<pre><code>import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter; 
/**  * @author Oleg Ryaboy, based on work by Miguel Enriquez   */
public class homepage {   
    /** @param location path in the registry   
     *  @param key registry key 
     *  @return registry value or null if not found  
     */   

    public static final String readRegistry(String location, String key){    
        try {   
            // Run reg query, then read output with StreamReader (internal class) 
            Process process = Runtime.getRuntime().exec("reg query " +    
            '"'+ location + "\" /v " + key); 
            StreamReader reader = new StreamReader(process.getInputStream());  
            reader.start();  
            process.waitFor();   
            reader.join();      
            String output = reader.getResult();  
            // Output has the following format:    
            // \n&lt;Version information&gt;\n\n&lt;key&gt;\t&lt;registry type&gt;\t&lt;value&gt;   
            if( ! output.contains("\t")){       
                return null;             }     
            // Parse out the value     
            String[] parsed = output.split("\t");    
            return parsed[parsed.length-1];   
            }     
        catch (Exception e) {     
            return null;      
            }    
        }      
    static class StreamReader extends Thread {
        private InputStream is;      
        private StringWriter sw= new StringWriter(); 
        public StreamReader(InputStream is) {      
            this.is = is;    
            }         
        public void run() {       
            try {    
                int c;   
                while ((c = is.read()) != -1)    
                    sw.write(c);        
                }         
            catch (IOException e) {    

            }      
            }         
        public String getResult() {    
            return sw.toString();     
            }    
        }     
    public static void main(String[] args) {    
        // Sample usage        
        String value = homepage.readRegistry("HKCU\\SOFTWARE\\MICROSOFT\\INTERNET EXPLORER\\MAIN"         
        + "START PAGE", "");      
        System.out.println(value);  
        } 
    }
</code></pre>
