安装 MSI 的批处理脚本 [英] Batch script to install MSI

查看:118
本文介绍了安装 MSI 的批处理脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试编写 .bat.

我正在尝试使用脚本安装 .msi,目前我们正在通过双击手动安装.

I am trying to install .msi using script, currently we are installing manually by double clicking on it.

来自的路径:d:/installed sw/$folder/.msi

路径:D:/program files/app/

$folder 意味着,每次都不同,因为我们正在安装新的 msi,这些 msi 在当前日期创建的文件夹中提供.

$folder means, it is different every time, as we are getting new msi to install which are provided in folder created by current date.

这是我正在尝试的脚本:

Here is the script I am trying:

@echo off
Title HOST: Installing Updates on %computername%
echo %computername%
set server=\SERVERNAME or PATHmsifolder
:select
cls
echo Select one of the Following MSI Install Folders for installation task.
echo.
dir %server% /A:D /B
SET /P MSI=Please enter the MSI Folder to install: 
SET source=%server%\%MSI%
echo Selected Installation %MSI%
echo.
echo.

:verify
ECHO Is This Correct?
echo.
echo.
ECHO 0: ABORT INSTALL
ECHO 1: YES
ECHO 2: NO,RE-SELECT
SET /p choice=Select YES, NO or ABORT? [0,1,2]:
     if /i [%choice%]==[0] endlocal&goto end
     if [%choice%]==[] goto BCurrentlocal
     if [%choice%]==[1] goto yes
 if [%choice%]==[2] goto no
 endlocal

:no
goto select
:yes
set FILENAME=%MSI%
call %source%\%FILENAME%.msi
echo beginning %MSI% installation
pause
echo Exiting Install Script....
PING -n 4 127.0.0.1 >nul
exit

根据set server,我添加了路径.

SET/P MSI 用于来自的路径.

但是,它不起作用.

谁能指导我我在做什么错误?

Can anyone guide me what mistake I am doing?

推荐答案

这是如何静默安装普通 MSI 文件:

msiexec.exe /i c:setup.msi /QN /L*V "C:Tempmsilog.log"

快速说明:

 /L*V "C:Tempmsilog.log"= verbose logging at indicated path
 /QN = run completely silently
 /i = run install sequence 

msiexec.exe 命令线 是广泛的,支持各种选项.这是同一命令行界面的另一个概述.这是一个 注释版本(已损坏,通过返回机器复活).

The msiexec.exe command line is extensive with support for a variety of options. Here is another overview of the same command line interface. Here is an annotated versions (was broken, resurrected via way back machine).

还可以使用等结构使批处理文件更短循环,如此处为 Windows 更新所示.

It is also possible to make a batch file a lot shorter with constructs such as for loops as illustrated here for Windows Updates.

如果有复选框必须在安装过程中选中,您必须找到合适的PUBLIC PROPERTIES 附加到复选框并在命令行中设置它,如下所示:

If there are check boxes that must be checked during the setup, you must find the appropriate PUBLIC PROPERTIES attached to the check box and set it at the command line like this:

msiexec.exe /i c:setup.msi /QN /L*V "C:Tempmsilog.log" STARTAPP=1 SHOWHELP=Yes

这些属性在每个 MSI 中都不同.您可以通过详细日志文件或在Orca 或其他合适的工具.您必须在对话框控件部分或属性表中查找属性名称.尝试运行安装程序并首先创建详细的日志文件,然后在日志中搜索设置属性..."消息.然后看看那里的属性名称是什么.然后将此属性与日志文件中的值一起添加到命令行.

These properties are different in each MSI. You can find them via the verbose log file or by opening the MSI in Orca, or another appropriate tool. You must look either in the dialog control section or in the Property table for what the property name is. Try running the setup and create a verbose log file first and then search the log for messages ala "Setting property..." and then see what the property name is there. Then add this property with the value from the log file to the command line.

另外看看如何使用转换来自定义 MSI,而不是设置命令行参数:如何更好地利用MSI文件

Also have a look at how to use transforms to customize the MSI beyond setting command line parameters: How to make better use of MSI files

这篇关于安装 MSI 的批处理脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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