Vec duze se mucim oko instaliranja i startovanja MySQL servisa iz mog programa koji sam uradio u VS2015, sa MySQL 5.7.21, evo dela programa. Molim za pomoc.
private void proveri_da_li_postoji_RisServis()
private void proveri_da_li_postoji_RisServis()
{
serviceExists = ServiceController.GetServices().All(s => s.Status.Equals("RisServis"));
//serviceExists = ServiceController.GetServices().All(s => s.Equals("RisServis"));
if(serviceExists == true)
{
wpostoji_RisServis = "D";
Process mysqlCloseCMD = new Process();
mysqlCloseCMD.StartInfo.FileName = appPath + "\\MySQL\\bin\\mysqlad.exe -u root shutdown";
mysqlCloseCMD.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
else
{
wpostoji_RisServis = "N";
}
}
private void instaliraj_RisServis()
{
//serviceExists = ServiceController.GetServices().Any(s => s.ServiceName == "RisServis");
//if(!serviceExists)
MessageBox.Show("POKUSAVAM DA INSTALIRAM RISSERVIS IZ INSTALIRAJ MySQL SA PUTA " + appPath);
try
{
ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();
ProcesServiceInstaller.Account = ServiceAccount.LocalService;
ProcesServiceInstaller.Username = "root";
ProcesServiceInstaller.Password = "xxxxxxxx";
ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
InstallContext Context = new System.Configuration.Install.InstallContext();
path = String.Format(appPath + "\\MySQL\\bin\\mysqld --install --local-services RisServis --defaults-file=" + appPath + "\\MySQL\\Data\\my.ini");
String[] cmdline = { path };
Context = new InstallContext("", cmdline);
ServiceInstallerObj.Context = Context;
ServiceInstallerObj.DisplayName = "RisServis";
ServiceInstallerObj.Description = "RisServis";
ServiceInstallerObj.ServiceName = "RisServis";
ServiceInstallerObj.StartType = ServiceStartMode.Automatic;
ServiceInstallerObj.Parent = ProcesServiceInstaller;
ServiceInstallerObj.DelayedAutoStart = true;
System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
ServiceInstallerObj.Install(state);
winstaliran_RisServis = "D";
MessageBox.Show("INSTALIRAO SAM RISSERVIS IZ INSTALIRAJ MySQL SA PUTA " + appPath);
}
catch(Exception x)
{
winstaliran_RisServis = "N";
MessageBox.Show("NISAM INSTALIRAO SAM RISSERVIS IZ INSTALIRAJ MySQL SA PUTA " + appPath);
}
}