Archive: Guess the service name


Guess the service name
Hi all,

the issue: I want to be sure that MySQL daemon is running. I can install MySQL in my own, create the service, then run it with a 'NET mysqlServiceName' command. If MySQL was installed before, I must check the daemon state, and start it if necessary. How can I guess the service name ? Because I can't handle services with sc or NET ... until I know the service name.

I can loop on all the services in the register at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\

and check for 'ImagePath' value. If it matches the path that I retrieved before in the installation key of MySQL, I can identify the service targetting the right instpath/bin/mysqld-nt.exe. But it is a long process.

Any good idea from you ?

Thks,


Gal'


No one on 61 readers has a comment ?

:(

Gal'


Not too much to go on here. You have a list of services and you need to find which one holds mysql.exe. You have to enumerate something... If you want to do it with code, you can check how tasklist /SVC does this.


Okay, thanks :)