2015-04-23 93 views
2

尝试使用powershell bat脚本卸载firefox。但我需要知道哪个Firefox版本正在运行,以及程序文件/下的文件夹名称是什么!我去了很多长脚本,如:https://p0w3rsh3ll.wordpress.com/2012/02/19/get-firefoxinfo/PowerShell:使用Powershell检查Firefox版本

但我只想要简单的东西,只是返回当前的Firefox版本。

+0

Get-WmiObject -Class Win32_Product将是检查安装的命令。 –

+2

不要使用** Get-WmiObject -Class Win32_Product **。它触发重新配置系统上安装的每个软件包。 [参考文献](http://serverfault.com/questions/203449/wmi-query-of-win32-product-creates-events-in-the-w2k8-application-event-log) –

回答

1

假设火狐安装在典型的位置:

wmic datafile where name='c:\\program files (x86)\\Mozilla Firefox\\Firefox.exe' get version 
1

刚刚尝试下面的PowerShell命令 -

PS> gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |Select DisplayName, DisplayVersion, Publisher, InstallDate, HelpLink, UninstallString |ogv 

enter image description here

这将显示一个弹出安装的所有版本的详细信息软件。在那里添加标准并将DisplayName设置为Firefox。

您将获得该版本。

在x64机器上,如果你想与GP做到这一点,你需要

PS> gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select DisplayName, DisplayVersion, Publisher, InstallDate, HelpLink, UninstallString |ogv 

谢谢!

2

Firefox specifically contains a command-line option to get the version,以及如何在Windows上使用它的说明。这一个班轮将让您的当前版本的Firefox(假设你在正确的文件夹是或您的Firefox是在系统路径):

$ffversion = [string](.\firefox.exe -v| Write-Output) 

| Write-Output位是至关重要的,就目前而言,由于记录的缺陷。然后将结果转换为字符串(也是必需的)并保存为变量。