Bonjour,
j'aimerai exécuter une commande Dos qui efface tous les fichiers *.doc d'un répertoire, avec mon programme Java, mais après un bon nombre de tentatives, cela ne fonctionne toujours pas. Est-ce que quelqu'un pourrait m'aider?
J'ai essayé ceci:
Process processDelDoc = Runtime.getRuntime().exec(new String[] {"cmd.exe", "/c", "del U:/MyUrl/MyFolder/*.doc"});
qui ne fait absolument rien (ni erreur, ni supression), et ceci:
Process processDelDoc = Runtime.getRuntime().exec("del U:/MyUrl/MyFolder/*.doc");
qui me créé cette erreur:
java.io.IOException: CreateProcess: del U:/MyUrl/MyFolder/*.doc error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:98)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:602)
at java.lang.Runtime.exec(Runtime.java:461)
at java.lang.Runtime.exec(Runtime.java:397)
at java.lang.Runtime.exec(Runtime.java:359)
at packet_ABC.Folder_Functions.Delete_OldDoc(Folder_Functions.java:481)
at packet_ABC.GUI_01$28.actionPerformed(Prestation_GED_GUI_01.java:1996)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1815)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1868)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:449)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:287)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:274)
at java.awt.Component.processMouseEvent(Component.java:5196)
at java.awt.Component.processEvent(Component.java:4993)
at java.awt.Container.processEvent(Container.java:1607)
at java.awt.Component.dispatchEventImpl(Component.java:3712)
at java.awt.Container.dispatchEventImpl(Container.java:1665)
at java.awt.Component.dispatchEvent(Component.java(Inlined Compiled Code))
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java(Compiled Code))
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3236)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3166)
at java.awt.Container.dispatchEventImpl(Container.java:1651)
at java.awt.Window.dispatchEventImpl(Window.java:1653)
at java.awt.Component.dispatchEvent(Component.java:3574)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:536)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:237)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:187)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:181)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:136)
Connaissez - vous une technique qui fonctionne?
Merci d'avance.
Partager