Więc mam oto kod:(na razie jeszcze nie okiełznany więc taki długi)
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
public class EdytorRejestru {
public static void DodajDoRejestru(/* String ścieżka */)
throws IOException, InterruptedException {
char h = '"';
// C:\WINDOWS\system32\screenshot107.png
String[] commands = { "reg delete " + h
+ "HKEY_CURRENT_USER\\Control Panel\\Desktop" + h + " /v lol" };
Process p = Runtime.getRuntime().exec(commands[0]);
InputStream in = p.getInputStream();
StreamReader reader = new StreamReader(p.getInputStream());
// String output = reader.getResult();
in.available();
int c;
while ((c = in.read()) != 1) {
System.out.print((char) c);
}
System.out.print("Ścieżka " + in.available());
}
public static void main(String[] args) throws IOException,
InterruptedException {
DodajDoRejestru();
char h = '"';
String[] commands = { "reg delete " + h
+ "HKEY_CURRENT_USER\\Control Panel\\Desktop" + h + " /v lol" };
System.out.println("Ścieżka " + commands[0]);
}
static class StreamReader extends Thread {
private InputStream is;
private StringWriter sw = new StringWriter();
public StreamReader(InputStream is) {
this.is = is;
}
public void run() {
try {
int c;
while ((c = is.read()) != -1)
sw.write(c);
} catch (IOException e) {
}
}
public String getResult() {
return sw.toString();
}
}
}
Po wykonaniu mam:** Delete the registry value lol (Y/N)? **
Pytanie brzmi jak zaakceptować?