高级安装程序使用命令行创建注册表

时间:2017-06-22 11:32:33

标签: powershell-v2.0 advanced-installer

我已经通过以下链接http://www.advancedinstaller.com/user-guide/new-reg.html使用命令行

创建注册表
$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

但我无法在安装后看到所需的注册表。安装软件后我需要的是以下内容

  

[HKEY_LOCAL_MACHINE \ SOFTWARE \ WOW6432Node \ MySoftware]   "路径" =" C:\ MySoftware"

     

[HKEY_LOCAL_MACHINE \ SOFTWARE \ WOW6432Node \ MySoftware \数据库]   " connectionstring" =" server =。; initial db = master"

同样在安装msi时,默认注册表被创建为My Company\Project我不想要

0 个答案:

没有答案
相关问题