Bonjour,

J'essaie d'exécuter un script bat qui nécessite le retour en ligne mais je ne réussit pas.

Mon code est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
string cmd1 = "cd C:\\Program Files (x86)\\SERVER\\ServerSQL\\Firebird_2_5\\"+ " \n" +"gbak.exe - USER DBA - PASSWORD 1234 - BACKUP " + path1 + path2; 
            ExecuteCommand(cmd1);
et le code d'exécution de la commande est le suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
static void ExecuteCommand(string command)
        {
            int exitCode;
            ProcessStartInfo processInfo;
            Process process;
            processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
            processInfo.CreateNoWindow = true;
            processInfo.UseShellExecute = false;
            // *** Redirect the output ***
            processInfo.RedirectStandardError = true;
            processInfo.RedirectStandardOutput = true;
 
            process = Process.Start(processInfo);
            process.WaitForExit();
 
            // *** Read the streams ***
            // Warning: This approach can lead to deadlocks, see Edit #2
            string output = process.StandardOutput.ReadToEnd();
            string error = process.StandardError.ReadToEnd();
 
            exitCode = process.ExitCode;
 
            Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
            Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
            Console.WriteLine("ExitCode: " + exitCode.ToString(), "ExecuteCommand");
            //////
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
 
            process.Close();
        }
Merci de votre aide!
BCDT,

Mon problème est la commande ne retourne pas à la ligne avant gbak.

Le problème se trouve dans la commande. Mais, j'arrive pas à trouver la solution.