2016-03-21 78 views
0

我需要創建安裝程序,該安裝程序會創建新的本地用戶,新文件夾並給予此用戶的完全權限。WIX創建用戶並使用他來授予文件夾的權限

我通過Visual Studio 2010中創建下面使用新的WiX的項目小試和維克斯3.10:

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 
    <Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="DG" UpgradeCode="85e3204f-c872-4229-bb75-fa5231863a75"> 
     <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> 

     <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 
     <MediaTemplate /> 

     <Feature Id="ProductFeature" Title="SetupProject1" Level="1"> 
      <ComponentGroupRef Id="ProductComponents" /> 
     </Feature> 

    <Feature Id='TestUserProductFeature' Title='Test User Product Feature' Level='1'> 
     <ComponentRef Id='TestUserProductComponent' /> 
    </Feature> 

    <InstallExecuteSequence> 
     <Custom Action='ConfigureUsers' Before='CreateFolders'/> 
    </InstallExecuteSequence> 
    </Product> 

    <Fragment> 
     <Directory Id="TARGETDIR" Name="SourceDir"> 
     <Component Id='TestUserProductComponent' Guid='652C2BE1-9DE7-47AD-A686-55ABAAF68B6F'> 
     <util:User Id='TEST_USER1' Name='testName1' Password='pa$$$$word' CreateUser='yes' FailIfExists='yes'/> 
     </Component> 
      <Directory Id="ProgramFilesFolder"> 
     <Directory Id="INSTALLFOLDER" Name="SetupProject1" > 
      <Directory Id="d_TestDirectory" Name="TestDirectory"> 
      <Component Id="CreateTestDirectory" Guid="8B7EB548-5767-7017-A56C-4EEBDDF7B621"> 
       <CreateFolder Directory="d_TestDirectory"> 
       <Permission User="testName1" GenericAll="yes" /> 
       </CreateFolder> 
      </Component> 
      </Directory> 
     </Directory> 
     </Directory> 
     </Directory>  
    </Fragment> 

    <Fragment> 
     <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">   
     <ComponentRef Id="CreateTestDirectory"/>  
     </ComponentGroup>  
    </Fragment> 
</Wix> 

請注意我說

<Custom Action='ConfigureUsers' Before='CreateFolders'/> 

爲新文件夾的創建之前創建的用戶。 同時請注意我說

FailIfExists='yes' 

爲UTIL:用戶因此將用戶是否存在故障。

當我使用日誌記錄運行我的msi時,首先收到此消息: 應用安全設置時發生錯誤。 testName1不是一個vaild用戶或組。這可能是軟件包的問題,​​或者是連接到網絡上的域控制器的問題。檢查您的網絡連接,然後單擊重試,或取消以結束安裝。

這意味着我的用戶沒有被創建。 然後我手動創建本地用戶,然後按重試。

然後我得到這個錯誤: 無法創建用戶(-2147022672 testName1) 這意味着,因爲它已經創建了安裝程序無法建立用戶(FailIfExists =「是」)

這是逆戟鯨我InstallExecuteSequence: FindRelatedProducts 25個 LaunchConditions 100 ValidateProductID 700 CostInitialize 800 FileCost 900個 CostFinalize 1000個 MigrateFeatureStates 1200 InstallValidate 1400 RemoveExistingProducts 14 01 InstallInitialize 1500個 ProcessComponents 1600 UnpublishFeatures 1800個 RemoveFolders 3600 ConfigureUsers 3699 CreateFolders 3700 RegisterUser 6000 RegisterProduct 6100個 PublishFeatures 6300 PublishProduct 6400 InstallFinalize 6600

這是記錄操作我的日誌文件的一部分:

Action start 0:02:47: RemoveFolders. 
Action ended 0:02:47: RemoveFolders. Return value 1. 
MSI (s) (D8:88) [00:02:47:389]: Doing action: ConfigureUsers 
MSI (s) (D8:88) [00:02:47:389]: Note: 1: 2205 2: 3: ActionText 
Action start 0:02:47: ConfigureUsers. 
MSI (s) (D8:28) [00:02:47:391]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIDFFA.tmp, Entrypoint: ConfigureUsers 
MSI (s) (D8:48) [00:02:47:391]: Generating random cookie. 
MSI (s) (D8:48) [00:02:47:392]: Created Custom Action Server with PID 1440 (0x5A0). 
MSI (s) (D8:E4) [00:02:47:409]: Running as a service. 
MSI (s) (D8:E4) [00:02:47:410]: Hello, I'm your 32bit Impersonated custom action server. 
MSI (s) (D8!30) [00:02:47:475]: PROPERTY CHANGE: Adding CreateUserRollback property. Its value is '**********'. 
MSI (s) (D8!30) [00:02:47:476]: Doing action: CreateUserRollback 
MSI (s) (D8!30) [00:02:47:476]: Note: 1: 2205 2: 3: ActionText 
Action start 0:02:47: CreateUserRollback. 
Action ended 0:02:47: CreateUserRollback. Return value 1. 
MSI (s) (D8!30) [00:02:47:477]: PROPERTY CHANGE: Adding CreateUser property. Its value is '**********'. 
MSI (s) (D8!30) [00:02:47:478]: Doing action: CreateUser 
MSI (s) (D8!30) [00:02:47:478]: Note: 1: 2205 2: 3: ActionText 
Action start 0:02:47: CreateUser. 
Action ended 0:02:47: CreateUser. Return value 1. 
Action ended 0:02:47: ConfigureUsers. Return value 1. 
MSI (s) (D8:88) [00:02:47:481]: Doing action: CreateFolders 
MSI (s) (D8:88) [00:02:47:481]: Note: 1: 2205 2: 3: ActionText 
Action start 0:02:47: CreateFolders. 
MSI (s) (D8:88) [00:02:47:481]: Note: 1: 1609 2: testName1 3: 1332 
MSI (c) (B4:B8) [00:02:47:483]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg 

Error 1609. An error occurred while applying security settings. testName1 is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. Unable to locate the user's SID, system error 1332 
MSI (s) (D8:88) [00:03:14:513]: 
MSI (s) (D8:88) [00:03:14:513]: Note: 1: 1609 2: testName1 3: 1332 
MSI (c) (B4:B8) [00:03:14:515]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg 

Error 1609. An error occurred while applying security settings. testName1 is not a valid user or group. This could be a problem with the package, or a problem connecting to a domain controller on the network. Check your network connection and click Retry, or Cancel to end the install. Unable to locate the user's SID, system error 1332 
MSI (s) (D8:88) [00:03:31:485]: 
MSI (s) (D8:88) [00:03:31:486]: Finished allocating new user SID 
MSI (s) (D8:88) [00:03:31:486]: Using well known SID for System 
MSI (s) (D8:88) [00:03:31:486]: Finished allocating new user SID 
Action ended 0:03:31: CreateFolders. Return value 1. 
MSI (s) (D8:88) [00:03:31:486]: Doing action: RegisterUser 
MSI (s) (D8:88) [00:03:31:486]: Note: 1: 2205 2: 3: ActionText 
Action start 0:03:31: RegisterUser. 
Action ended 0:03:31: RegisterUser. Return value 1. 
MSI (s) (D8:88) [00:03:31:487]: Doing action: RegisterProduct 
MSI (s) (D8:88) [00:03:31:487]: Note: 1: 2205 2: 3: ActionText 
Action start 0:03:31: RegisterProduct. 
MSI (s) (D8:88) [00:03:31:487]: Note: 1: 2262 2: Media 3: -2147287038 
MSI (s) (D8:88) [00:03:31:488]: PROPERTY CHANGE: Adding ProductToBeRegistered property. Its value is '1'. 
Action ended 0:03:31: RegisterProduct. Return value 1. 
MSI (s) (D8:88) [00:03:31:488]: Doing action: PublishFeatures 
MSI (s) (D8:88) [00:03:31:488]: Note: 1: 2205 2: 3: ActionText 
Action start 0:03:31: PublishFeatures. 
Action ended 0:03:31: PublishFeatures. Return value 1. 
MSI (s) (D8:88) [00:03:31:489]: Doing action: PublishProduct 
MSI (s) (D8:88) [00:03:31:489]: Note: 1: 2205 2: 3: ActionText 
Action start 0:03:31: PublishProduct. 
MSI (s) (D8:88) [00:03:31:490]: Note: 1: 2205 2: 3: Icon 
MSI (s) (D8:88) [00:03:31:490]: Note: 1: 2228 2: 3: Icon 4: SELECT `Name`, `Data` FROM `Icon` 
MSI (s) (D8:88) [00:03:31:490]: Note: 1: 2262 2: Media 3: -2147287038 
Action ended 0:03:31: PublishProduct. Return value 1. 
MSI (s) (D8:88) [00:03:31:490]: Doing action: InstallFinalize 
MSI (s) (D8:88) [00:03:31:490]: Note: 1: 2205 2: 3: ActionText 
Action start 0:03:31: InstallFinalize. 
MSI (s) (D8:88) [00:03:31:491]: Running Script: C:\Windows\Installer\MSIDFE9.tmp 
MSI (s) (D8:88) [00:03:31:491]: PROPERTY CHANGE: Adding UpdateStarted property. Its value is '1'. 
MSI (s) (D8:88) [00:03:31:491]: Machine policy value 'DisableRollback' is 0 
MSI (s) (D8:88) [00:03:31:493]: Note: 1: 1402 2: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Installer\Rollback\Scripts 3: 2 
MSI (s) (D8:88) [00:03:31:494]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1216610392,LangId=1033,Platform=0,ScriptType=1,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1) 
MSI (s) (D8:88) [00:03:31:494]: Executing op: ProductInfo(ProductKey={718267EA-D291-4ED2-8BA6-F3B872BEA874},ProductName=SetupProject1,PackageName=SetupProject1.msi,Language=1033,Version=16777216,Assignment=1,ObsoleteArg=0,,,PackageCode={413012CF-A56C-4342-9DE3-50774CA5DD67},,,InstanceType=0,LUASetting=0,RemoteURTInstalls=0,ProductDeploymentFlags=2) 
MSI (s) (D8:88) [00:03:31:494]: Executing op: DialogInfo(Type=0,Argument=1033) 
MSI (s) (D8:88) [00:03:31:494]: Executing op: DialogInfo(Type=1,Argument=SetupProject1) 
MSI (s) (D8:88) [00:03:31:495]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1]) 
MSI (s) (D8:88) [00:03:31:495]: Executing op: SetBaseline(Baseline=0,) 
MSI (s) (D8:88) [00:03:31:495]: Executing op: SetBaseline(Baseline=1,) 
MSI (s) (D8:88) [00:03:31:495]: Executing op: ActionStart(Name=ProcessComponents,Description=Updating component registration,) 
MSI (s) (D8:88) [00:03:31:495]: Executing op: ProgressTotal(Total=2,Type=1,ByteEquivalent=24000) 
MSI (s) (D8:88) [00:03:31:495]: Executing op: ComponentRegister(ComponentId={652C2BE1-9DE7-47AD-A686-55ABAAF68B6F},KeyPath=C:\,State=3,,Disk=1,SharedDllRefCount=0,BinaryType=0) 
MSI (s) (D8:88) [00:03:31:496]: Executing op: ComponentRegister(ComponentId={8B7EB548-5767-7017-A56C-4EEBDDF7B621},KeyPath=C:\Program Files (x86)\SetupProject1\TestDirectory\,State=3,,Disk=1,SharedDllRefCount=0,BinaryType=0) 
MSI (s) (D8:88) [00:03:31:496]: Executing op: ActionStart(Name=CreateUserRollback,,) 
MSI (s) (D8:88) [00:03:31:496]: Executing op: CustomActionSchedule(Action=CreateUserRollback,ActionType=11521,Source=BinaryData,Target=**********,CustomActionData=**********) 
MSI (s) (D8:88) [00:03:31:497]: Executing op: ActionStart(Name=CreateUser,,) 
MSI (s) (D8:88) [00:03:31:497]: Executing op: CustomActionSchedule(Action=CreateUser,ActionType=11265,Source=BinaryData,Target=**********,CustomActionData=**********) 
MSI (s) (D8:64) [00:03:31:498]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI8C49.tmp, Entrypoint: CreateUser 
MSI (s) (D8:48) [00:03:31:498]: Generating random cookie. 
MSI (s) (D8:48) [00:03:31:499]: Created Custom Action Server with PID 2476 (0x9AC). 
MSI (s) (D8:E4) [00:03:31:517]: Running as a service. 
MSI (s) (D8:E4) [00:03:31:517]: Hello, I'm your 32bit Elevated custom action server. 
CreateUser: Error 0x800708b0: failed to create user: testName1 
MSI (c) (B4:B8) [00:03:31:600]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell Dlg 

Error 26401. Failed to create user. (-2147022672 testName1  ) 
MSI (s) (D8!58) [00:04:07:562]: Product: SetupProject1 -- Error 26401. Failed to create user. (-2147022672 testName1  ) 

CustomAction CreateUser returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) 
Action ended 0:04:07: InstallFinalize. Return value 3. 
MSI (s) (D8:88) [00:04:07:566]: User policy value 'DisableRollback' is 0 
MSI (s) (D8:88) [00:04:07:566]: Machine policy value 'DisableRollback' is 0 
MSI (s) (D8:88) [00:04:07:567]: Executing op: Header(Signature=1397708873,Version=500,Timestamp=1216610416,LangId=1033,Platform=0,ScriptType=2,ScriptMajorVersion=21,ScriptMinorVersion=4,ScriptAttributes=1) 
MSI (s) (D8:88) [00:04:07:567]: Executing op: DialogInfo(Type=0,Argument=1033) 
MSI (s) (D8:88) [00:04:07:567]: Executing op: DialogInfo(Type=1,Argument=SetupProject1) 
MSI (s) (D8:88) [00:04:07:568]: Executing op: RollbackInfo(,RollbackAction=Rollback,RollbackDescription=Rolling back action:,RollbackTemplate=[1],CleanupAction=RollbackCleanup,CleanupDescription=Removing backup files,CleanupTemplate=File: [1]) 
MSI (s) (D8:88) [00:04:07:569]: Executing op: ActionStart(Name=CreateUser,,) 
MSI (s) (D8:88) [00:04:07:569]: Executing op: ProductInfo(ProductKey={718267EA-D291-4ED2-8BA6-F3B872BEA874},ProductName=SetupProject1,PackageName=SetupProject1.msi,Language=1033,Version=16777216,Assignment=1,ObsoleteArg=0,,,PackageCode={413012CF-A56C-4342-9DE3-50774CA5DD67},,,InstanceType=0,LUASetting=0,RemoteURTInstalls=0,ProductDeploymentFlags=2) 
MSI (s) (D8:88) [00:04:07:569]: Executing op: ActionStart(Name=CreateUserRollback,,) 
MSI (s) (D8:88) [00:04:07:569]: Executing op: CustomActionRollback(Action=CreateUserRollback,ActionType=11521,Source=BinaryData,Target=**********,CustomActionData=**********) 
MSI (s) (D8:C8) [00:04:07:571]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI1929.tmp, Entrypoint: RemoveUser 
MSI (s) (D8:88) [00:04:07:950]: Executing op: ActionStart(Name=ProcessComponents,Description=Updating component registration,) 
MSI (s) (D8:88) [00:04:07:950]: Executing op: ComponentUnregister(ComponentId={8B7EB548-5767-7017-A56C-4EEBDDF7B621},ProductKey={718267EA-D291-4ED2-8BA6-F3B872BEA874},BinaryType=0,) 
MSI (s) (D8:88) [00:04:07:950]: Executing op: ComponentUnregister(ComponentId={652C2BE1-9DE7-47AD-A686-55ABAAF68B6F},ProductKey={718267EA-D291-4ED2-8BA6-F3B872BEA874},BinaryType=0,) 
MSI (s) (D8:88) [00:04:07:950]: Executing op: End(Checksum=0,ProgressTotalHDWord=0,ProgressTotalLDWord=0) 
MSI (s) (D8:88) [00:04:07:950]: Error in rollback skipped. Return: 5 
MSI (s) (D8:88) [00:04:07:953]: Note: 1: 2318 2: 
MSI (s) (D8:88) [00:04:07:953]: Calling SRSetRestorePoint API. dwRestorePtType: 13, dwEventType: 103, llSequenceNumber: 38, szDescription: "". 
MSI (s) (D8:88) [00:04:07:954]: The call to SRSetRestorePoint API succeeded. Returned status: 0. 
MSI (s) (D8:88) [00:04:07:954]: Unlocking Server 
MSI (s) (D8:88) [00:04:08:135]: PROPERTY CHANGE: Deleting UpdateStarted property. Its current value is '1'. 
Action ended 0:04:08: INSTALL. Return value 3. 

因此,它看起來像CreateUser實際上是在InstallFinalize操作期間以另一個臨時DLL的高級(已緩存)自定義操作運行的。 即使ConfigureUsers被說成在CreateFolders之前運行,它只是計劃提升的自定義操作。

我的情況可能實現嗎?哪裏不對?

回答

0

目前還不清楚你在做什麼即時自定義操作 - 他們永遠不會改變系統,因爲沒有辦法撤消它們。所有改變系統的自定義操作都需要延遲,以便a)使用回滾CA進行回滾,並且b)提升運行,因爲不立即提升CA.如果一些CA依賴於其他人,則只需適當地訂購它們。

CreateUser錯誤0x8007089a表示「指定的用戶名無效。」。如果顯示「vmtest \ user」的跟蹤代碼正確,那可能不正確。爲什麼是反斜槓? 「用戶」部分是密碼嗎?另外我不相信跟蹤會顯示密碼,所以用戶名可能是「vmtest \ user」,並且反斜槓作爲用戶名的一部分是無效的。

+0

我創建了一個小測試,重現了這個問題。它正在創建避免反斜槓的用戶,並嘗試爲該用戶創建具有完全權限的文件夾。 似乎我無法達到以下操作順序:1.創建用戶2使用他來授予新文件夾的權限,因爲創建用戶操作計劃稍後以高級方式運行,這就是我如何理解到此刻 – dogrishin