For a windows script I am writing, I need to detect if the machine has Apache 2.2 installed, and to find the application path.
对于我正在编写的Windows脚本,我需要检测机器是否安装了Apache 2.2,并找到应用程序路径。
One solution I came up with is to wget http://localhost:8080/server-info and parse the root and the config file from it. This would fail if the server does not use port 8080
我提出的一个解决方案是wget http:// localhost:8080 / server-info并解析root和配置文件。如果服务器不使用端口8080,则会失败
Another option would be to call “sc qc Apache2.2” and to parse the returning string. This would fail if the server is not installed as a service, or is using a different name.
另一种选择是调用“sc qc Apache2.2”并解析返回的字符串。如果服务器未作为服务安装或使用其他名称,则会失败。
Is there any better way to do that?
有没有更好的方法呢?
2 个解决方案
#1
2
Not a lot of great options if they didn't install it using the installer. If they used the MSI/installer, you can check the registry:
如果他们没有使用安装程序安装它,那么没有很多好的选择。如果他们使用MSI /安装程序,您可以检查注册表:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot
HKEY_CURRENT_USER\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot
You can also check the running process list:
您还可以检查正在运行的进程列表:
WMIC PROCESS get Caption,Commandline,Processid
Look for the appropriate EXE. If for some reason you needed the port number, then use netstat and search for the appropriate port.
寻找合适的EXE。如果由于某种原因您需要端口号,请使用netstat并搜索相应的端口。
Also, when you say "a windows script", I am assuming you are using something modern and capable like Windows Scripting Host (my favorite) or PowerShell. Don't even bother with batch files.
此外,当你说“一个Windows脚本”时,我假设你正在使用现代的功能,如Windows Scripting Host(我最喜欢的)或PowerShell。甚至不打扰批处理文件。
#2
0
As I recall, Apache writes some registry keys. If you know how to read them from a script, that might help.
我记得,Apache写了一些注册表项。如果您知道如何从脚本中读取它们,那可能会有所帮助。
#1
2
Not a lot of great options if they didn't install it using the installer. If they used the MSI/installer, you can check the registry:
如果他们没有使用安装程序安装它,那么没有很多好的选择。如果他们使用MSI /安装程序,您可以检查注册表:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot
HKEY_CURRENT_USER\SOFTWARE\Apache Software Foundation\Apache\2.2.2\ServerRoot
You can also check the running process list:
您还可以检查正在运行的进程列表:
WMIC PROCESS get Caption,Commandline,Processid
Look for the appropriate EXE. If for some reason you needed the port number, then use netstat and search for the appropriate port.
寻找合适的EXE。如果由于某种原因您需要端口号,请使用netstat并搜索相应的端口。
Also, when you say "a windows script", I am assuming you are using something modern and capable like Windows Scripting Host (my favorite) or PowerShell. Don't even bother with batch files.
此外,当你说“一个Windows脚本”时,我假设你正在使用现代的功能,如Windows Scripting Host(我最喜欢的)或PowerShell。甚至不打扰批处理文件。
#2
0
As I recall, Apache writes some registry keys. If you know how to read them from a script, that might help.
我记得,Apache写了一些注册表项。如果您知道如何从脚本中读取它们,那可能会有所帮助。