检查是否有程序存在,如果不安装它 [英] Check if a program exists and if not to install it

查看:149
本文介绍了检查是否有程序存在,如果不安装它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个詹金斯建立与NSIS文件。我需要一个脚本来检查,如果设备上安装了某个程序,如果没有,就应该从安装文件夹中安装的。exe的。我对安装工作的所有.exe文件的安装文件夹必需的。

I am writing a Jenkins build with an NSIS file. I need a script to check if the device has a certain program installed on it and if it doesn't, it should install the .exe's from the installer folder. I have all the .exe's in the install folder required for the installer to work.

这应该是相当简单的,但我在这种情况下,百思不得其解,但没有找到这个在任何地方的任何信息。

This should be rather simple but i am baffled in this case and could not find any information about this anywhere.

推荐答案

我想你使用的是Windows环境。你可以写一个PowerShell脚本来检查它:

I suppose you are using a windows environment. You could write a powershell script to check it:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName | Select-String 'Microsoft Visual C\+\+'

这将列出所有安装了Visual C ++可再分发

This will list all installed Visual C++ Redistributables

在我的机器,它看起来像:

On my machine it looks like that:

@{DisplayName=Microsoft Visual C++ 2005 Redistributable (x64)}
@{DisplayName=Microsoft Visual C++ 2010  x64 Redistributable - 10.0.40219}
@{DisplayName=Microsoft Visual C++ 2012 x64 Additional Runtime - 11.0.61030}
@{DisplayName=Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161}
@{DisplayName=Microsoft Visual C++ 2005 Redistributable (x64)}
@{DisplayName=Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.17}
@{DisplayName=Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.21005}
@{DisplayName=Microsoft Visual C++ 2013  x64 Designtime - 12.0.21005}
@{DisplayName=Microsoft Visual C++ 2015 x64 Debug Runtime - 14.0.23506}
@{DisplayName=Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.23506}
@{DisplayName=Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.21005}
@{DisplayName=Microsoft Visual C++ 2012 x64 Debug Runtime - 11.0.60610}
@{DisplayName=Microsoft Visual C++ 2005 Redistributable (x64)}
@{DisplayName=Microsoft Visual C++ 2015 x64 Additional Runtime - 14.0.23506}
@{DisplayName=Microsoft Visual C++ 2013 x64 Debug Runtime - 12.0.21005}
@{DisplayName=Microsoft Visual C++ 2012 x64 Minimum Runtime - 11.0.61030}

所以,如果你要检查你的程序叫做 ProgramWithName 只需使用:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName | Select-String ProgramWithName

如果你想知道是否安装了SQL Server的使用:

If you want to know if the SQL Server is installed use:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName | Select-String 'Microsoft SQL Server 2014 Express'

这给你我的机器上:

this gives you on my machine:

@{DisplayName=Microsoft SQL Server 2014 Express LocalDB }

这篇关于检查是否有程序存在,如果不安装它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆