.net - Setup/Running PostgreSQL From C# -
my requirements follows:
- once application starts postgresql service started application
- once application closes postgresql service closed application
- ... taking care of postgresql setup , running scripts , starting service etc
how doing @ present is:
- when start postgresql in new process redirecting
redirectstandarderror,redirectstandardoutput, silent start, user cannot see command window etc
the problem is,
- when coded looked message strings , supported english. in other words, used string
successinredirectstandardoutputsupporting multiple languages comparison fails.
is there way can find out whether postgresql set started , postgresql service running or not?
i starting postgresql calling pg_ctl.exe in separate process.
(we doing similar) star postgres service using batch file
"c:\program files\postgresql\9.0\bin\pg_ctl.exe" -d "c:\program files\postgresql\9.0\data" start and [stopping] service
"c:\program files\postgresql\9.0\bin\pg_ctl.exe" -d "c:\program files\postgresql\9.0\data" stop where c:\program files\postgresql\9.0\bin\pg_ctl.exe location of installation of postgresql u can
hkey_local_machine\software\postgresql\installations\postgresql-9.0 now on running batch file check if service indeed running can use code process running check postgres.exe if running or not.
also 1. checking-if-windows-application-is-running 2. how-can-i-know-if-a-process-is-running
public bool isprocessopen(string name) { //here we're going list of running processes on //the computer foreach (process clsprocess in process.getprocesses()) { //now we're going see if of running processes //match running processes. sure not //add .exe name provide, i.e: notepad, //not notepad.exe or false returned if //notepad running. //remember, if have process running more once, //say ie open 4 times loop thr way close 4, //if want close first 1 finds //then add return; after kill if (clsprocess.processname.contains(name)) { //if process found running //return true return true; } } //otherwise return false return false; }
Comments
Post a Comment