2011-02-25 107 views
9

我使用下面的腳本NSIS:如何讓NSIS從臨時目錄安裝並執行文件?

Name "My app wrapper" 
Outfile "MyAppSetup.exe" 
InstallDir $TEMP\MyApp\Install 
Function .onInit 
SetSilent silent 
FunctionEnd 
Section "" 
    SetOutPath $TEMP\MyApp\Install 
    File installer.msi 
    File setup.exe 
    Exec setup.exe 
SectionEnd 

的目的是,安裝程序將包裹起來這兩個文件,installer.msi和SETUP.EXE(這是安裝prereqs,然後調用安裝引導程序.msi)到MyApp Setup.exe文件中。當運行MyAppSetup.exe時,它應該將installer.msi和setup.exe提取到$ Temp \ MyApp \ Install目錄,並且它應該從該目錄運行setup.exe。

但是,當我從桌面運行MyAppSetup時,它會執行它在桌面上找到的setup.exe文件,而我甚至在C:\ Temp中看不到MyApp \ Install目錄。

我需要做些什麼才能讓此腳本將文件安裝到正確的位置並執行正確的文件?

回答

2

我不知道這是否會解決你的問題,但我會寫:

Exec $TEMP\MyApp\Instal\setup.exe 

你肯定$ TEMP指向C:/ Temp文件夾?你檢查了嗎?

+0

啊,你說得對。它指向AppData中的某些內容。我現在在那裏看到那些文件。它將文件放在正確的位置。我認爲完整的道路也是解決方案。這是我之前嘗試過的,但我認爲出於某種原因,我沒有獲得最新版本的安裝程序。 – 2011-02-25 17:59:01

12
Section 
InitPluginsDir 
SetOutPath "$pluginsdir\MyApp\Install" ;It is better to put stuff in $pluginsdir, $temp is shared 

File installer.msi 
File setup.exe 

ExecWait '"$pluginsdir\MyApp\Install\setup.exe"' ;You should always use full paths and proper quotes 

SetOutPath $exedir ;Change current dir so $temp and $pluginsdir is not locked by our open handle 
SectionEnd 
+0

$ pluginsdir比$ temp有什麼好處?什麼是$ pluginsdir? – nawfal 2013-08-13 17:23:22

+0

@nawfal $ pluginsdir在$ temp內部,並自動刪除你... – Anders 2013-08-13 20:45:02

+0

謝謝,我把它挖了一些閱讀.. – nawfal 2013-08-13 22:09:08

0

這是另一種方式來做到這一點

Function .onInit 

    InitPluginsDir 
     File /oname=$PLUGINSDIR\test.exe "test.exe" 

FunctionEnd 

Section "Exec file" SecFile 

    nsExec::Exec $PLUGINSDIR\test.exe 

SectionEnd 
相關問題