title: Open webpage from a Java application doesn't work when run from task scheduler
body: <p>I wrote a Java program some time ago that automatically opens a webpage before I get to work in the morning. I do this by calling a batch file from Java, which opens the webpage. This program worked great for about three or four months without any problems, but one day it just stopped working. I have tried opening the webpage from within Java as well instead of the batch file, but I consistently run into a problem. This is the process I use:</p>
  
  <ul>
  <li>I exported my program as a runnable JAR and converted it to an EXE using Launch4j. In my Windows task scheduler I schedule it to run at 5:30am every morning.</li>
  <li>My Java program calls the batch file that is stored on my desktop</li>
  <li>The batch file opens Chrome and calls the webpage to open</li>
  </ul>
  
  <p>When I run the Java program EXE manually (double-click from the desktop) it runs correctly, calls the batch file, and opens the webpage. However, when I try running the EXE from the Windows task scheduler it does not (visibly) open the webpage. It does appear to run Chrome in the background (according to the task manager/Process Explorer) but the webpage itself doesn't seem to open (I can tell because the webpage I open should be playing music, but I hear nothing). </p>
  
  <p>This is the Java function I use to run the batch file:</p>
  
  <pre><code>public static void openWebpage() throws Exception {
      String[] startupBat = {"cmd", "/c", "start", "/B", System.getProperty("user.home") + "\\Desktop\\WebpageStart.bat"};
      ProcessBuilder pb = new ProcessBuilder(startupBat);
      try {
          webpage = pb.start();
      } catch (IOException e) {
          logWriter.write(tf.format(new Date()).toString() + " - Unable to start webpage");
      }
      if (webpage != null) {
          try {
              webpage.waitFor();
          } catch (InterruptedException e) {
              logWriter.write(tf.format(new Date()).toString() + " - Webpage startup interrupted");
          } finally {
              webpage.destroy();
          }
      }
  }
  </code></pre>
  
  <p>And here are the contents of the batch file I use to start the webpage:</p>
  
  <pre><code>@echo off
  
  start "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://www.myWebpage.com
  </code></pre>
  
  <p>Once again, everything works fine when I run the Java EXE manually, but when I try to run it from the task scheduler the webpage doesn't appear to open. What could cause this sort of behavior? What changes when the task scheduler runs a program vs. when it is manually run?</p>