I want to check in my Java application whether the Windows virtual keyboard is working or not.
I searched for it and found that I can use wmic.exe to search for the process.
This is what I do:
Process proc = Runtime.getRuntime().exec("wmic.exe"); BufferedReader input = new BufferedReader(new InputStreamReader(proc .getInputStream())); OutputStreamWriter oStream = new OutputStreamWriter(proc .getOutputStream()); oStream .write("process where name='osk.exe' get caption"); oStream .flush(); oStream .close(); input.readLine(); while ((in = input.readLine()) != null) { if (in.contains("osk.exe")) { input.close(); proc.destroy(); return; } } input.close(); proc.destroy();
This works, but wmic somehow creates the file TempWmicBatchFile.bat with the line process where name='osk.exe' get caption .
How can I prevent this?
source share