2011-05-05 80 views
0

我正在編寫使用NSIS的安裝程序,該程序將向計算機的GPO添加條目以在系統引導時運行命令。將條目添加到GPO啓動腳本的安裝程序

# From http://nsis.sourceforge.net/LGP_Startup/Shutdown_Script 
!include LGPScript.nsh 

Section 
    SetOutPath - 

    # Install all files from myprog directory into C:\Program Files\myprog 
    File myprog\* 

    # Copy mysystweak.bat to System32\GroupPolicy\Machine\Scripts\Startup 
    SetOutPath $SYSDIR\GroupPolicy\Machine\Scripts\Startup 
    File myprog\mysystweak.bat 
    SetOutPath - 

    # Add GPO entry to execute mysystweak.bat on startup 
    ${LGPScript::Create} 'Startup' 'mysystweak.bat' '' $R1 
    DetailPrint "Create startup LGP return code:$R1" 

    # Write uninstaller 
    Writeuninstaller "${uninstall_name}" 
SectionEnd 

一切順利的話,除了什麼也不顯示在... \啓動。安裝程序認爲一切工作:

Output folder: C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Startup 
Extract: mysystweak.bat... 100% 
Output folder: C:\Program Files (x86)\myprog 

我最初嘗試使用CopyFiles從$ INSTDIR批處理文件複製到... \啓動,但得到了同樣的結果。

這裏怎麼回事?

相關:https://serverfault.com/q/266338/2101

回答

1

如果這是你需要禁用FS重定向X64的系統,沒有它$ SYSDIR不會指向真正的system32目錄下:

!include x64.nsh 

Section 
... 
SetOutPath $SYSDIR\GroupPolicy\Machine\Scripts\Startup 
${DisableX64FSRedirection} 
File myprog\mysystweak.bat 
${EnableX64FSRedirection} 
... 
SectionEnd 

您可以驗證這是通過觀看安裝程序的問題Process Monitor

+0

這就是問題並且完全解決 - 謝謝!爲什麼安裝者不能這麼說... – MikeyB 2011-05-05 19:21:04

+0

@MikeyB:它會怎麼知道?只有在真正需要時才能禁用重定向,因爲其他操作(CreateShortcut等)可能必須從system32加載dll,並且需要從32位system32加載這些dll!安裝程序基本上不可能知道您的批處理文件是否應該位於實際或重定向的$ sysdir中... – Anders 2011-05-05 20:20:21

+0

@MikeyB:另外,如果\ GroupPolicy \ Machine \ Scripts \ Startup路徑默認情況下不存在您可能想要在DisableX64FSRedirection塊內移動SetOutPath調用... – Anders 2011-05-05 20:21:30

相關問題