Check for mysql installation
-
Hi I want to problematically determine if mysql is installed on my machine or not. Please help
I'd try WMI and look for the MySQL service.
-
I'd try WMI and look for the MySQL service.
-
Hi I want to problematically determine if mysql is installed on my machine or not. Please help
sumit7034 wrote:
I want to problematically determine...
really? :-D it could be installed but not running, so maybe it is better to check for a process, with a name that contains "mysql"; the exact name may depend on the implementation, my XAMPP package launches a "mysqld" process. See Process.GetProcessesByName() :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
It's something like:
System.Management.ManagementScope oMs = new System.Management.ManagementScope(@"\\localhost");
oMs.Path.NamespacePath = @"root\cimv2";
string query = "select * From Win32_Service Where Name Like \"%mysql%\"";
System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery(query);
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();
foreach (ManagementObject oReturn in oReturnCollection)
{
foreach (PropertyData propertyData in oReturn.Properties)
{
txtResult.Text += string.Format("{0}: {1}\r\n", propertyData.Name, propertyData.Value);
}
}This writes all information available on all services containing "mysql" in their name into textbox "txtResult". Note also the "State" and "Started" properties.