Search code examples
c#databaseprocessorientdborientdb-2.1

Run orientdb server from c#


I try run OrientDB server from c# code. When I run via Powershell my database works, but when I try run from code I get error like don't have connect to db. I thought problem is how long process starts but I used Thread.Sleep(20000) after processOrient.Start and it didn't help too. Other servers starts very well from code (but .exe files) My code:

 ProcessStartInfo processInfoOrient = new ProcessStartInfo()
 {
       FileName = @"B:\db\orientdb-3.0.29\bin\server.bat",           
       RedirectStandardError = true,
       RedirectStandardOutput = true,
       UseShellExecute = false,
       CreateNoWindow = false,
       WorkingDirectory = @"B:\db\orientdb-3.0.29\bin"
 };

 Process processOrient = new Process();
 processOrient.StartInfo = processInfoOrient;
 processOrient.Start();

How Can I do that? Thanks.


Solution

  • In order to run bat-file you need to have UseShellExecute = true.