![](/img/trans.png)
[英]How to remove installation folder when app is uninstalled? Installation folder happens to be locked by msiexec.exe process
[英]How to reference MSI files in a different folder when executing msiexec.exe command in windows batch file?
我编写了一个 windows 批处理脚本来安装一些 MSI 文件,其中我的所有 MSI 文件与批处理脚本位于同一文件夹中,并且我使用“%~dp0”来引用我的 MSI 文件的路径。 这是我之前使用的命令并且工作正常:
msiexec.exe /i "%~dp0TestMSI.msi" ALLUSERS=1 REINSTALLMODE=vomus /lv*v "C:\Program Files (x86)\Test\TestInstall.log" /qn
但现在我试图将所有 MSI 文件存储在一个单独的文件夹中,并尝试使用相同的 msiexec.exe 命令访问它们。 此外,我不应该使用 MSI 的完整文件路径(例如:“C:/Test/MSIs/TestMSI.msi”),因为该位置将来可能会发生变化,这会破坏我的脚本。
我虽然这会起作用,但它不起作用:
msiexec.exe /i "%~dp0..\MSIs\TestMSI.msi" ALLUSERS=1 REINSTALLMODE=vomus /lv*v "C:\Program Files (x86)\Test\TestInstall.log" /q
有什么方法可以在 msiexec.exe 命令中引用不同文件夹(在本例中为“MSIs”文件夹)中的 MSI 文件? 我尝试了很多方法并查看了文档,但没有一个成功。
pushd
到目录并将/i
路径重置为文件名:
@echo off
pushd "%~dp0..\MSIs"
msiexec.exe /i "TestMSI.msi" ALLUSERS=1 REINSTALLMODE=vomus /lv*v "C:\Program Files (x86)\Test\TestInstall.log" /q
popd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.