How to stop wscript.exe from java to stop a mysql server? <p>I am trying to stop wscript that was started from a java application using Runtime.getRuntime().exec("") method.I started a mysql server using wscript.But wscript is not closing when I close my java application,because of this when I restart my application every time 80% of memory is filled with wscript.exe making my pc slow. So my question is how to safely close wscript.exe after its use is over.If this question was asked before someone please point me in right direction</p> <pre><code> public void startMySQLServer() { try { Process process = Runtime.getRuntime().exec("wscript C:\\\\\\\\Users\\\\\\\\Shersha\\\\\\\\Documents\\\\\\\\NetBeansProjects\\\\\\\\Berries\\\\\\\\batch\\\\\\\\mysql_start.vbs"); System.out.println("waiting to start mysql server"); process.waitFor(); System.out.println("mysql server started sucessfully"); } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException ex) { Logger.getLogger(DataBaseManager.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre> <p><a href="https://i.stack.imgur.com/TMyd8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMyd8.jpg" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/WSqt3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WSqt3.jpg" alt="enter image description here"></a></p> <p>EDITED</p> <pre><code>public void stopMySQLServer() { try { Process process = Runtime.getRuntime().exec("wscript C:\\\\\\\\Users\\\\\\\\Shersha\\\\\\\\Documents\\\\\\\\NetBeansProjects\\\\\\\\Berries\\\\\\\\batch\\\\\\\\mysql_stop.vbs"); System.out.println("waiting to stop mysql server"); process.waitFor(); process.destroy(); System.out.println("process exit value" + process.exitValue()); System.out.println("mysql server stopped sucessfully"); } catch (InterruptedException e) { e.printStackTrace(); } catch (IOException ex) { Logger.getLogger(DataBaseManager.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre> <p>EDITED 2 mysql_start.vbs</p> <pre><code>Set WshShell = WScript.CreateObject("WScript.Shell") If WScript.Arguments.length = 0 Then Set ObjShell = CreateObject("Shell.Application") ObjShell.ShellExecute "wscript.exe", """" &amp; _ WScript.ScriptFullName &amp; """" &amp;_ " RunAsAdministrator", , "runas", 1 Wscript.Quit End if CreateObject("Wscript.Shell").Run "C:\Users\Shersha\Documents\NetBeansProjects\Berries\batch\mysql_start.bat",0,True </code></pre>