![](/img/trans.png)
[英]Windows TaskScheduler - Run locally an executable from a remote server in a batch file
[英]Run portable Qt app executable from batch file
Windows快捷方式具有絕對路徑,這些絕對路徑在將文件移動到其他驅動器時不會被引用。 我希望用戶單擊一個與子目錄中所有Qt dll文件分開的文件,而不是快捷方式。
我創建了一個批處理文件,該文件位於可執行文件上方的1個目錄中,帶有一個運行文件的相對路徑。
release
+ db
+ plugins
+ platforms
+ iconengines
+ imageformats
- Qt5Core.dll
- program.exe
- etc....
program.bat
//paths set in main()
QCoreApplication::AddLibraryPath("plugins");
我發現以下代碼來自這個問題 :
@start "" "\release\program.exe"
但是,運行時會顯示錯誤消息“無法找到Windows。”
我也嘗試過
@start "" "release\program.exe"
@start "" "%CD%\release\program.exe"
@start "" "%~dp0\release\program.exe"
但是我遇到一個關於Qt找不到“ windows”平台插件的錯誤,這似乎表明路徑有問題。
為什么程序會使用Windows快捷方式正確運行,而批處理文件卻失敗?
我已經在您程序的父文件夾中用您的內容創建了program.bat, 它可以正常工作 。
已在未安裝Qt的計算機上進行了測試。 操作系統是Windows 7
這是示例應用程序結構
bin
+ platforms
+ iconengines
+ imageformats
- Qt5Core.dll
- program.exe
- etc....
program.bat
program.bat包含:
@start "" "bin\program.exe"
因此,請確保您的應用程序部署正確。
我在我的pro文件中使用此命令來確保每個版本都正確部署:
# Deployment
CONFIG (release, release|debug) {
win32 {
QMAKE_POST_LINK = windeployqt $${DESTDIR}/$${TARGET}.exe --no-translations
# Not necessary when path to VC libraries is correctly set
externalLibs.files += somepath/_windeploy_/msvcr120.dll
externalLibs.files += somepath/_windeploy_/msvcp120.dll
externalLibs.path = $$DESTDIR
# need to add additional build step (make): install
INSTALLS += externalLibs
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.