![](/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.