10

I need to detect if MongoDB is installed on a Windows machine in my app installer.

Does anyone know what I can look for in the registry to be sure it is installed?

I've searched the entire registry and researched on SO and google for hours. Mongo registry entries are using GUID keys, so these change per install and I don't think I can find it this way in innosetup.

I'm hoping someone has already solved this problem and can help me so I don't have to spend more hours reinventing the wheel. Thanks to anyone with useful information.

trashrobber
  • 727
  • 2
  • 9
  • 26

4 Answers4

8

The default installation directory for MongoDB on Windows would be: C:\Program Files\MongoDB

Reference: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/

Also, Detecting installed programs via registry for the registry angle!

For more information, google!

Community
  • 1
  • 1
Bey0ndZ
  • 114
  • 3
  • `C:\Program Files\` may not exist; it's different on Win7 64-bit depending on whether you're running a 32 or 64 bit app, for instance, or on Windows 8, or if it's been configured to be somewhere else, or if the language isn't English. (For more information, google!) MongoDB also may not be installed in the default installation directory. IOW, this isn't an answer to the question. – Ken White Jul 25 '14 at 19:32
  • Thanks for trying. That's the same link admdrew gave above for detecting programs in the registry, unfortunately mongo is not added to the registry this way, but under GUID keys. Detecting if it is installed in one of the program files locations is what I am doing now, but like Ken White said, it's not really the correct way. Yes I have done a fair bit of googling this, if you find an answer there I have overlooked please share it with me! – trashrobber Jul 25 '14 at 19:40
5

Open the command prompt and type "cd c:\program files\mongodb\server\your version\bin". After you enter the bin folder type "mongo start". If you get either a successful connection or failed one it means it's installed at least.

Diego Alves
  • 2,462
  • 3
  • 32
  • 65
4

The problem is that the user could have installed MongoDB via a zip file -- so there wont be any trace of the installation in the registry at all. You could go the extra mile and try to connect to the standard 27017 port and try to get a status, but what if mongodb is not running at the moment? There is no good answer here -- simply ask the user if he has MongoDB installed and whats the directory. Its not very "automated" but in this case, it is more reliable and less problematic.

alernerdev
  • 2,014
  • 3
  • 19
  • 35
  • Also, what if mongo isn't running on the default port, or is only bound to a particular interface? What if they choose to run Mongo in a docker container or a VM? that probably doesn't affect your application but you will be hard pressed to find evidence. I think asking them for the mongo connection details is the best option here – James Fry Feb 10 '17 at 21:30
0

Searching for the file mongod.exe in all the files might work in this case, if user has installed from zip file still this method will work.

sumitkanoje
  • 1,217
  • 14
  • 22