简体   繁体   English

批处理文件以静默方式安装多个程序

[英]Batch file to install multiple programs silently

I want to create a batch file which will install multiple programs sequentially. 我想创建一个批处理文件,它将按顺序安装多个程序。 I am able to install the required softwares sequentially using following code in batch file: 我可以使用批处理文件中的以下代码顺序安装所需的软件:

@echo off
"Path/software1.exe"
"Path/software2.exe"
"Path/software3.exe"
"Path/software4.exe"

OR 要么

@echo off
start /wait "Path/software1.exe"
start /wait "Path/software2.exe"
start /wait "Path/software3.exe"
start /wait "Path/software4.exe"

But here before installing any software I want to check if it is already installed or not. 但在安装任何软件之前,我想检查它是否已安装。

I have tried getting the list of installed softwares using following two ways: 我尝试使用以下两种方式获取已安装软件的列表:

wmic product get name

OR 要么

reg export HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall temp.txt /y

But then I would have to search strings which isn't feasible. 但是我必须搜索不可行的字符串。 Thus I would like to know if their is any command to check if a particular application is installed or not using a batch file? 因此,我想知道他们是否有任何命令来检查是否使用批处理文件安装了特定的应用程序? Thanks in advance. 提前致谢。

There's no formal way to check to see if an application is installed. 没有正式的方法来检查是否安装了应用程序。 Installers, for the most part, just copy files, set registry keys, and add start menu shortcuts without registering anything with Windows to say, I'm installed. 安装程序,大多数情况下,只需复制文件,设置注册表项,添加开始菜单快捷方式,而无需在Windows上注册任何内容,我已经安装了。

A generic way to see if an application is installed is to see if it has an entry in the Add/Remove Programs applet of Control Panel. 查看是否安装了应用程序的一般方法是查看它是否在“控制面板”的“添加/删除程序”小程序中有一个条目。 Each entry in the ARP is found in the registry at : Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall (of both HKEY_CURERNT_USER and HKEY_LOCAL_MACHINE) ARP中的每个条目都可以在注册表中找到: Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall (HKEY_CURERNT_USER和HKEY_LOCAL_MACHINE)

If it is MSI based installer, then you probably can write some code to see if the Feature ID or Component ID is installed with the MSI API . 如果它是基于MSI的安装程序,那么您可能可以编写一些代码以查看功能ID或组件ID是否随MSI API一起安装。 I wouldn't know how to invoke those functions in a BAT file without compiling some helper programs. 我不知道如何在不编译某些帮助程序的情况下在BAT文件中调用这些函数。

you just take conditions 你只是条件

if not exist "C:\\Program Files\\software1" 如果不存在“C:\\ Program Files \\ software1”
"Path/software1.exe" “路径/ software1.exe”

if not exist "C:\\Program Files\\software2" 如果不存在“C:\\ Program Files \\ software2”
"Path/software2.exe" “路径/ software2.exe”

if not exist "C:\\Program Files\\software3" 如果不存在“C:\\ Program Files \\ software3”
"Path/software3.exe" “路径/ software3.exe”

if not exist "C:\\Program Files\\software4" 如果不存在“C:\\ Program Files \\ software4”
"Path/software4.exe" “路径/ software4.exe”

This may help (which I use to help show installed software following a completed batch) is to put "appwiz.cpl" without quotations at the end of your script. 这可能有所帮助(我用它来帮助显示完成批次后安装的软件)是在脚本末尾放置“appwiz.cpl”而不引用。

example: 例:

@echo off
C:\WINDOWS\system32>
cd C:/ (assuming files are located here)
echo You are about to install software1,2,3, press ENTER to proceed...
pause
"path\software1.exe"
"path\software2.exe"
"path\software3.exe"
appwiz.cpl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM