Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

executer une commande dos a partir d'un code java

Featured Replies

Posté(e)

bonjour

j'ai écrit un code qui ouvre une fenettre DOS

import java.io.*;


public class Test2 {

/**
 * @param args
 * @throws IOException 
 */
public static void main(String[] args) throws IOException 
{

	 Runtime runtime = Runtime.getRuntime();
	 String[] cmd={"cmd.exe","/C start cmd.exe"};
	 Process p = runtime.exec(cmd,null,null );
	// String[] cmd4={"cmd.exe","/C start cmd.exe"};
	 //Process p4 = runtime.exec(cmd4,null,null );

	// TODO Auto-generated method stub

}

}

et je cherche à executer une commande dans cette fenettre je fais comment à partir de Java?

Posté(e)

il faut que tu redirige l'entrée standard pour le cmd.exe que tu lances vers un flux dont tu as le contrôle, puis que tu écrives dessus les commandes à lancer. :D

Posté(e)
  • Auteur
il faut que tu redirige l'entrée standard pour le cmd.exe que tu lances vers un flux dont tu as le contrôle, puis que tu écrives dessus les commandes à lancer. :francais:

ok et comment ça se fait (je ne suis qu'un pauvre débutant en java)

Posté(e)
  • Auteur

import java.io.*;
import java.lang.*;
import java.awt.*;

/**
*
* @author Harold Harvey
*/
public class Test2
{

/**
 * @param args the command line arguments
 */
public static void main(String[] args) throws IOException
{
	try
	{
		// Runtime runtime = Runtime.getRuntime();
		String[] cmd={"C:\\WINDOWS\\System32\\cmd.exe","/C start test.bat"};
		Process p = Runtime.getRuntime().exec(cmd);
	// TODO code application logic here
	}
	catch(IOException e)
{
	System.err.println("echec de l'execution du script: "+e);
	System.exit(1);
}
}
}

voilà c'est fait.

j'ai réussi à executer meme un script a partir du code java.

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.