title: How to start GNU Octave with GUI through Cygwin from a desktop icon?
body: <p>Since GNU Octave comes wit a GUI since versions 3.8.0, I thought I should check it out.</p>
  
  <p>So since I run Windows and could only find Octave 3.8 for Cygwin, I installed Cygwin and the packages <code>octave</code>, <code>xinit</code>, <code>xlaunch</code> and <code>gnuplot</code> (according to <a href="http://octave.1599824.n4.nabble.com/Octave-3-8-1-on-Cygwin-Packages-td4664258.html" rel="nofollow noreferrer">this page</a>, but I don't know if all those packages are needed).</p>
  
  <p>Then, when trying to start Octave with the GUI from Cygwin with <code>octave --force-gui</code>, I initially got the error message</p>
  
  <pre><code>octave: X11 DISPLAY environment variable not set
  </code></pre>
  
  <p>and Octave would start in console mode. So I found <a href="http://petpari.blogspot.se/2013/04/octave-gnuplot-using-cygwins-x-server.html" rel="nofollow noreferrer">this page</a>, which told me to run</p>
  
  <pre><code>echo "export DISPLAY=:0.0" &gt;&gt;~/.bash_profile
  </code></pre>
  
  <p>from Cygwin, to permanently get rid of the error message, which worked. However, then I instead got this error message:</p>
  
  <pre><code>octave: unable to open X11 DISPLAY
  </code></pre>
  
  <p>The same page also said that you have to run the X Server by going to Start -> Cygwin-X -> XWin Server. That worked, but since I don't want the xterm terminal to start since it is not needed, I found <a href="https://superuser.com/questions/435768/how-do-i-prevent-cygwins-xwin-server-automatically-starting-xterm">this page</a> which told me to run</p>
  
  <pre><code>touch ~/.startxwinrc
  </code></pre>
  
  <p>from Cygwin to create an empty <code>.startxwinrc</code> file, to prevent the xtrem terminal from starting by default, which worked. The same page also mentioned that the X Server can be started directly from Cygwin with the command <code>startxwin</code>.</p>
  
  <p>So, now I can start Octave with the GUI from Cygwin, simply by running</p>
  
  <pre><code>startxwin
  octave --force-gui
  </code></pre>
  
  <p>However, I would like to just be able to double click on a desktop icon to get everything up and running.</p>
  
  <p><strong>So, to my question:</strong> <em>Can I somehow put this in a script file, which when I run it, will be opened in Cygwin so that the commands in the script file will be run in Cygwin? And is there some way to automatically close the X Server after Octave has terminated?</em> I've tried writing a file <code>octave.bat</code>, which starts Cygwin and gives a second batch file as argument, which in turn contains the commands I want to execute. But when I run the first script, I just get bombarded with command prompts (not Cygwin prompts), and the all say</p>
  
  <pre><code>'startxwin' is not recognized as an internal or external command, operable program or batch file.
  </code></pre>
  
  <p>Why is the second script not opened in Cygwin, and how can I achieve what I want as simply as possible?</p>