I'm using a code to "open / close the disk drawer" however it creates a file on the desktop and would like to sort out some other way to resolve it.
package controller;
import java.awt.Desktop;
import java.io.File;
import java.io.PrintWriter;
public class disc_1 {
public static void main(String[] args) {
try {
//********Start VBScript code to open cd tray************
String a = "Set oWMP = CreateObject(\"WMPlayer.OCX\")" + "\n"
+ "Set colCDROMs = oWMP.cdromCollection" + "\n"
+ "For d = 0 to colCDROMs.Count - 1" + "\n"
+ "colCDROMs.Item(d).Eject" + "\n"
+ "Next" + "\n"
+ "set owmp = nothing" + "\n"
+ "set colCDROMs = nothing" + "\n"
+ "wscript.Quit(0)";
//********End VBScript code to open cd tray************
File myCdTrayOpener = new File("OpenCdTray.vbs");
PrintWriter pw = new PrintWriter(myCdTrayOpener);
pw.print(a);
pw.flush();
pw.close();
Desktop.getDesktop().open(myCdTrayOpener);
myCdTrayOpener.deleteOnExit();
} catch (Exception exception) {
exception.printStackTrace();
} finally {
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
//********Start VBScript code to open cd tray************
String a = "Set oWMP = CreateObject(\"WMPlayer.OCX\")" + "\n"
+ "Set colCDROMs = oWMP.cdromCollection" + "\n"
+ "For d = 0 to colCDROMs.Count - 1" + "\n"
+ "colCDROMs.Item(d).Eject" + "\n"
+ "colCDROMs.Item(d).Eject" + "\n"
+ "Next" + "\n"
+ "set owmp = nothing" + "\n"
+ "set colCDROMs = nothing" + "\n"
+ "wscript.Quit(0)";
//********End VBScript code to open cd tray************
File myCdTrayOpener = new File("OpenCdTray.vbs");
PrintWriter pw = new PrintWriter(myCdTrayOpener);
pw.print(a);
pw.flush();
pw.close();
Desktop.getDesktop().open(myCdTrayOpener);
myCdTrayOpener.deleteOnExit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
}