2014-04-11 35 views
3

我有以下CustomAction複製命令不能正常工作使用維克斯自定義操作

<CustomAction Id="CopyToSystem32" ExeCommand="copy /y 64bits.txt C:\Windows\System32" Directory="INSTALLFOLDER" Impersonate="no" Execute="deferred" Return="asyncWait" /> 

<InstallExecuteSequence> 
    <Custom Action="CopyToSystem32" After="InstallFiles" >VersionNT64</Custom> 
</InstallExecuteSequence> 

因此,當它檢測到64位操作系統,它將複製文件到System32文件夾中。如果我用.bat文件執行它,它可以正常工作。但我更喜歡它是一個批處理命令。

日誌說以下內容:

MSI (s) (74:AC) [10:08:33:473]: Executing op: ActionStart(Name=CopyToSystem32,,) 
Action 10:08:33: CopyToSystem32. 
MSI (s) (74:AC) [10:08:33:473]: Executing op:   CustomActionSchedule(Action=CopyToSystem32,ActionType=3234,Source=C:\Program Files (x86)\SetupProject\,Target=copy /y 64bits.txt C:\Windows\System32,) 
MSI (s) (74:AC) [10:08:33:474]: Executing op:  ActionStart(Name=RegisterProduct,Description=Registering product,Template=[1]) 
Action 10:08:33: RegisterProduct. Registering product 
MSI (s) (74:AC) [10:08:33:474]: Executing op: ChangeMedia(,MediaPrompt=Please insert the disk:  ,MediaCabinet=1\cab1.cab,BytesPerTick=0,CopierType=1,,,SignatureRequired=0,,,IsFirstPhysicalMedia=1) 
MSI (s) (74:AC) [10:08:33:474]: Executing op:  DatabaseCopy(DatabasePath=C:\Windows\Installer\32ea43.msi,ProductCode={0C013216-61FB-4283-AF0A- 6CB264019F5B},,,) 
MSI (s) (74:AC) [10:08:33:474]: Note: 1: 1402 2:  UNKNOWN\Products\612310C0BF163824FAA0C62B4610F9B5\InstallProperties 3: 2 
1: CopyToSystem32 2: 1631  

爲什麼我ExeCommand是不是抄襲我的文件的任何想法?

謝謝!

回答

5

AFAIK copy是命令解釋程序的一部分,而不是自己的命令。 E ..g你可以檢查,如果你是例如在Windows文件夾中執行dir copy.* /s。沒有獨立執行copy的文件。 你可以做什麼:預先設置命令解釋程序的調用,例如:

cmd /c copy /y 64bits.txt C:\Windows\System32 

/c -parameter告訴解釋執行後關閉(你也可以使用,而不是cmd的​​-environment變量)。您也可以使用CAQuietExecute自定義操作來防止cmd彈出,如here所述。
也許你也可以使用CopyFile-element來完成你的任務?這樣你就不必處理外殼窗口等。

+0

哇,完美!只是!我也會看看你提到的CAQuiteExecute。再次感謝! A ++++ – Sonhja

+0

我忘了使用'xcopy.exe'或'robocopy.exe'代替'cmd/c copy'的其他可能性。兩者都可以在'System32'文件夾中找到。但是,如果可能的話,最簡單和最優雅的方法是使用Windows Installer/WiX提供的機制,即如果可能的話使用'CopyFile'元素。 – taffit

相關問題