It is supposed to be easy, but I can't get it work.
When I run the following command inside cmd, it works perfectly fine. When I run the command inside the c# code, it won't do anything (no exception has been thrown either).
Here is the command I'm using (which works perfectly fine when using directly on cmd.exe):
cd %ProgramFiles%\PostgreSQL\12\bin && SET PGPASSWORD=mypassword&& pg_restore.exe -U username -d dbname C:\file\to\dump\my.dump
Here is what I'm trying to do in c# (not working):
var arg = @"cd %ProgramFiles%\PostgreSQL\12\bin && SET PGPASSWORD=mypassword&& pg_restore.exe -U username -d dbname C:\file\to\dump\my.dump";
Process.Start("cmd.exe", arg);
Am I missing something? I found a lot of posts concerning c# starting a process, but nothing solved my problem. I also tried to start the process with StartInfo and added the Properties like Arguments, FileName, etc., but it did not work either.
Be aware, the question process.start() arguments is not the same - in my case, I neet to set the system variable (SET PGPASSWORD), since pg_restore has no password argument.