J'ai allégé ma précédente version, été oblige:)
import java.io.*;
import java.util.regex.*;
public class GestEvt
{
public static void main(String[] args)
{
try
{
BufferedReader bufferedReaderForInput = null;
String InputChoice;
System.out.println("Veuillez choisir le type de fichier à sélectionner :");
System.out.println("1 : System");
System.out.println("2 : Application");
System.out.println("3 : Security");
bufferedReaderForInput = new BufferedReader(new InputStreamReader(System.in));
while(!(InputChoice = bufferedReaderForInput.readLine()).matches("([1]|[2]|[3])"))
{
System.out.println("Veuillez choisir le type de fichier à sélectionner :");
System.out.println("1 : System");
System.out.println("2 : Application");
System.out.println("3 : Security");
bufferedReaderForInput = new BufferedReader(new InputStreamReader(System.in));
}
String cmdLine = "";
if (InputChoice.equals("1"))
cmdLine = "cmd.exe /c eventquery.vbs /fo CSV /l system > SysEvt.txt";
if (InputChoice.equals("2"))
cmdLine = "cmd.exe /c eventquery.vbs /fo CSV /l application > AppEvt.txt";
if (InputChoice.equals("3"))
cmdLine = "cmd.exe /c eventquery.vbs /fo CSV /l security > SecEvt.txt";
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec(cmdLine);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Ne pas oublier le "cscript //h:cscript //s" en ligne de commande avant
de lancer le prog.
Bonne chance
J'ai allégé ma précédente version, été oblige:)
import java.io.*; import java.util.regex.*; public class GestEvt { public static void main(String[] args) { try { BufferedReader bufferedReaderForInput = null; String InputChoice; System.out.println("Veuillez choisir le type de fichier à sélectionner :"); System.out.println("1 : System"); System.out.println("2 : Application"); System.out.println("3 : Security"); bufferedReaderForInput = new BufferedReader(new InputStreamReader(System.in)); while(!(InputChoice = bufferedReaderForInput.readLine()).matches("([1]|[2]|[3])")) { System.out.println("Veuillez choisir le type de fichier à sélectionner :"); System.out.println("1 : System"); System.out.println("2 : Application"); System.out.println("3 : Security"); bufferedReaderForInput = new BufferedReader(new InputStreamReader(System.in)); } String cmdLine = ""; if (InputChoice.equals("1")) cmdLine = "cmd.exe /c eventquery.vbs /fo CSV /l system > SysEvt.txt"; if (InputChoice.equals("2")) cmdLine = "cmd.exe /c eventquery.vbs /fo CSV /l application > AppEvt.txt"; if (InputChoice.equals("3")) cmdLine = "cmd.exe /c eventquery.vbs /fo CSV /l security > SecEvt.txt"; Runtime runtime = Runtime.getRuntime(); Process proc = runtime.exec(cmdLine); } catch (Exception e) { e.printStackTrace(); } } }Ne pas oublier le "cscript //h:cscript //s" en ligne de commande avant
de lancer le prog.
Bonne chance