Com32
January 14, 2020, 5:37am
1
First off, thanks for making such an amazing software suite, and all but giving it away. I’m trying to build an installer, that runs a script after it unpacks everything during the install routine. Technically I would also want to do the same thing during an uninstall and repair if possible.
Here is is what I have so far… which seems to do everything, sans run the powershell script during install. Any direction that can be given will be greatly appreciated!!
New-Installer -Product "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e84' -Content {
New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder" -Content {
New-InstallerDirectory -DirectoryName "My First Product" -Content {
New-InstallerFile -Id "testcmd" -Source "C:\installer\install_customcommand.ps1"
Get-ChildItem ("C:\service_loop\*") -Recurse | New-InstallerFile -Verbose
}
}
New-InstallerCustomAction -FileId "testcmd" -RunOnInstall
} -Output (Join-Path $PSScriptRoot "output") -RequiresElevation -Verbose
2 Likes
adam
January 14, 2020, 6:54pm
2
Glad you’re enjoying it! I’ll have to take a look. From what I can tell, that looks fine so not quite sure why it isn’t executing the script.
Com32
January 14, 2020, 6:58pm
3
Thanks so much! I’m not sure if this helps… but for now this is what the install script looks like.
Write-Output "I ran correctly" | Out-File -FilePath c:\sasc\installertest.log -Force
adam
January 14, 2020, 10:15pm
4
Ah! I see the issue. There is a CustomAction parameter on New-Installer. Try this.
New-Installer -Product "My First Product" -UpgradeCode '1a73a1be-50e6-4e92-af03-586f4a9d9e84' -Content {
New-InstallerDirectory -PredefinedDirectory "ProgramFilesFolder" -Content {
New-InstallerDirectory -DirectoryName "My First Product" -Content {
New-InstallerFile -Id "testcmd" -Source "C:\installer\install_customcommand.ps1"
Get-ChildItem ("C:\service_loop\*") -Recurse | New-InstallerFile -Verbose
}
}
} -Output (Join-Path $PSScriptRoot "output") -RequiresElevation -Verbose -CustomAction @(New-InstallerCustomAction -FileId "testcmd" -RunOnInstall)
1 Like
Com32
January 14, 2020, 11:16pm
5
OH that makes sense! I’ll give a go tonight.
Thanks so much!
1 Like
Com32
January 15, 2020, 5:31am
6
Worked perfectly! Thanks so much again for your help!
1 Like