2017-06-22 2 views
0

Je suis passé par le lien suivant http://www.advancedinstaller.com/user-guide/new-reg.html pour créer des registres en ligne de commandeprogramme d'installation préalable de créer un registre en ligne de commande

$InstallerName = "Installer1.2.10" 
$registryParams ="/edit $aippath /NewReg -RegKey HKLM\Software\MYApplication\Database\*" 
$SourceDir = "D:\AdvanceInstaller" 
$AdvanceInstallerPath = Get-ChildItem "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object {Get-ItemProperty $_.PSPath} | Where-Object {$_.DisplayName -match "Advanced Installer"} 
$InstallerPath= "$($AdvanceInstallerPath.InstallLocation)bin\x86\AdvancedInstaller.com" 
$aippath = "$SourceDir\$($InstallerName).aip" 
$ProductName = "MYApplication" 

$DeleteReg = "/edit $aippath /DelReg -RegKey HKLM\SOFTWARE\WOW6432Node\MyApplication" 
$ProductParams = "/edit $aippath /SetProperty ProductName=$ProductName" 
$repository = "/edit $aippath /SetAppdir -buildname DefaultBuild -path C:\MyApplication" 
$newParameters = "/newproject $aippath -type enterprise" 
$buildParams = "/build $aippath" 

Start-Process -FilePath $InstallerPath -ArgumentList $newParameters -Wait -WindowStyle Hidden -ErrorAction Stop 
Start-Process -FilePath $InstallerPath -ArgumentList $ProductParams -Wait -WindowStyle Hidden -ErrorAction Stop 
Start-Process -FilePath $InstallerPath -ArgumentList $repository -Wait -WindowStyle Hidden -ErrorAction Stop 
$pinfo = New-Object System.Diagnostics.ProcessStartInfo 
$pinfo.FileName = "$InstallerPath" 
$pinfo.RedirectStandardError = $true 
$pinfo.RedirectStandardOutput = $true 
$pinfo.UseShellExecute = $false 
$pinfo.Arguments = "$DeleteReg" 

$p = New-Object System.Diagnostics.Process 
$p.StartInfo = $pinfo 
$p.Start() | Out-Null 
$p.WaitForExit() 

$stdout = $p.StandardOutput.ReadToEnd() 
$stderr = $p.StandardError.ReadToEnd() 
Write-Host $stdout 
Write-Host $stderr 
Start-Process -FilePath $InstallerPath -ArgumentList $buildParams -Wait -WindowStyle Hidden -ErrorAction Stop 
Start-Process -FilePath $InstallerPath -ArgumentList $registryParams -Wait -WindowStyle Hidden -ErrorAction Stop 

Mais je suis incapable de voir le registre souhaité créé après l'installation. Ce que je dois est que par ce qui suit après l'installation du logiciel

[HKEY_LOCAL_MACHINE \ SOFTWARE \ WOW6432Node \ MySoftware] "Path" = "C: \ MySoftware"

[HKEY_LOCAL_MACHINE \ SOFTWARE \ WOW6432Node \ MySoftware \ Database] "connectionstring" = "server = initial db = .; maître"

également lors de l'installation du msi le registre par défaut est créé comme se My Company\Project que je ne veux pas

Répondre

0

Après beaucoup de traînée et d'erreur voici le code final

$InstallerName = "Installer1.2.10" 
$SourceDir = "D:\AdvanceInstaller" 
$AdvanceInstallerPath = Get-ChildItem "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object {Get-ItemProperty $_.PSPath} | Where-Object {$_.DisplayName -match "Advanced Installer"} 
$InstallerPath= "$($AdvanceInstallerPath.InstallLocation)bin\x86\AdvancedInstaller.com" 
$aippath = "$SourceDir\$($InstallerName).aip" 
$ProductName = "MyApplication" 

$DeleteReg = "/edit $aippath /DelReg -regkey HKUD\Software\[Manufacturer]" 
Start-Process -FilePath $InstallerPath -ArgumentList $DeleteReg -Wait -WindowStyle Hidden -ErrorAction Stop 
$registryParams = "/edit $aippath /NewReg -RegKey HKUD\Software\MyApplication -data ''" 
$registryParams1 = "/edit $aippath /NewReg -RegValue HKUD\Software\MyApplication\path -data C:\MyApplication" 
Start-Process -FilePath $InstallerPath -ArgumentList $registryParams -Wait -WindowStyle Hidden -ErrorAction Stop 
Start-Process -FilePath $InstallerPath -ArgumentList $registryParams1 -Wait -WindowStyle Hidden -ErrorAction Stop