开发者

Starting a service which may have port conflicts with existing service

Is there any way to start a service and force a service that is already running to stop if it uses the port that the service I want to start is going to be using?

I'm going to be installing apache and mys开发者_如何学Goql, and want the services to be running without having to manually stopping existing services that use port 80/3306 such as existing apache/mysql services.

I'm using NSIS to make my installer.


To find the process listening on port 80 perhaps you could do the equivilent of this from the command line:

c:\>netstat -aon | findstr 0.0:80
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       3488

3488 is the process id. Not sure what APIs netstat is using though.

Without disabling or reconfiguring the service that is already using the desired port is still going to cause problems on system restart. The best bet might be to abort the install if the port is already in use. To check if a port is in use, use this NSIS TCP plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜