Ask Your Question

Custom Fact for Firefox Version (Windows)

asked 2015-07-14 10:41:28 -0500

johnnyb04 gravatar image

updated 2015-07-14 11:58:51 -0500

I'd like to write a custom fact for Windows that holds the current version of Firefox. Using the command line, the version of Firefox can be found by using the command: C:\"Program Files (x86)\Mozilla Firefox"\firefox.exe -v | more

This command outputs the version of Firefox AND a newline. So for instance it will display...


{new line}

This is a problem because facter stores my "firefox_version" fact as blank. If any of you Windows command line gurus have a way to remove the new line, I'd love to know it! :) One of the best solutions I've found is to use Powershell to remove the newline using the powershell command: C:\"Program Files (x86)\Mozilla Firefox"\firefox.exe -v | more | Select -First 1

I've looked at the question here, but it is very confusing on what quotes should be used and how it should be applied in the exec line. Do you guys know how I could use this or maybe some other solution to store the version of Firefox in facter on a Windows machine?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-07-21 09:29:36 -0500

johnnyb04 gravatar image

updated 2015-07-22 13:18:40 -0500

I was able to create a custom fact that pulled the version from the registry. Below is my ruby script:

Facter.add("firefox_version") do confine :kernel => :windows setcode do reg_type=Win32::Registry::KEY_READ | 0x100'SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox') regkey=reg['CurrentVersion'].to_s.split(' ').first reg.close regkey end end

edit flag offensive delete link more

answered 2015-07-15 10:55:41 -0500

MichaelSmith gravatar image

It appears you're stuck at how to invoke a fact using Powershell, or whether there are better alternatives.

Custom executable facts on Windows are supported as far back as Facter 1.7.3 (, so the simplest approach is to create a .ps1 file containing

$x = (C:\"Program Files (x86)\Mozilla Firefox"\firefox.exe -v | more | Select -First 1)
Write-Host hello=$x

If for some reason you can't use Powershell, there are some ways to hack things in a batch command described at, but batch files are more finicky and I haven't gotten an example working.

edit flag offensive delete link more


Thanks for the help! I went about it a different way, but I've seemed to have found a solution.

johnnyb04 gravatar imagejohnnyb04 ( 2015-07-21 09:31:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2015-07-14 10:41:28 -0500

Seen: 486 times

Last updated: Jul 22 '15