Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choco New creates a bad ChocolateyUninstall.ps1 script which does not work. #460

Closed
pauby opened this issue Oct 12, 2015 · 5 comments
Closed
Assignees
Milestone

Comments

@pauby
Copy link
Member

pauby commented Oct 12, 2015

When using Choco New to create a new ChocolateyInstall.ps1 and ChocolaetyUninstall.ps1 script the uninstall one is bad. See below:

$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) ` -ErrorAction SilentlyContinue` | ? { $_.DisplayName -like "$softwareName" }

if ($key.Count -eq 1) {
...

That if statement will never execute as when $key only has one value it's not an Array so doesn't have a Count method. The fix is to force $key to be an array:

[array]$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) ` -ErrorAction SilentlyContinue` | ? { $_.DisplayName -like "$softwareName" }

if ($key.Count -eq 1) {

I would just submit a pull request but I have no idea where it gets the script or if it generates it on the fly.

@ferventcoder
Copy link
Member

That was a late acceptance. I guess we didn't check over that good enough. You can see the script at https://github.com/chocolatey/choco/blob/master/src/chocolatey/infrastructure.app/templates/ChocolateyUninstallTemplate.cs

@ferventcoder ferventcoder added this to the 0.9.10 milestone Oct 12, 2015
@pauby
Copy link
Member Author

pauby commented Oct 12, 2015

Thanks. I've submitted a pull request for the amendment.

@AeliusSaionji
Copy link

I've found a case which causes the current template to fail (and is unrelated to the [array])

Pesky UninstallString: "C:\WINDOWS\SysWOW64\RunDll32.EXE" "C:\Program Files\NVIDIA Corporation\Installer2\InstallerCore\NVI2.DLL",UninstallPackage Display.GFExperience

$silentArgs = '-silent'

Error log
https://gist.github.com/Link-Satonaka/35452023a6f97faae5b3

@chrsmith
Copy link

For reference, if you are being bitten by this by running choco new -a ... the fix can be seen here:
https://github.com/chocolatey/choco/pull/462/files

Specifically, prefix $key with [array]:

[array]$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) `
                               -ErrorAction SilentlyContinue `
                | ? { $_.DisplayName -like "$softwareName" }

@ferventcoder
Copy link
Member

Yep, we are working on that one still.

@ferventcoder ferventcoder self-assigned this Mar 29, 2016
ferventcoder added a commit that referenced this issue Mar 29, 2016
* stable:
  (GH-460) Amended Template
  (GH-623) Extract Nuspec on Install
  (GH-674)(GH-672) Color Overrides / Fix Write-Host
  (GH-181) log selection to log file only
  (GH-181)(GH-184) Short prompt/Prompt character
  (GH-675) Template include LICENSE/VERIFICATION
  (GH-258) Rename zip to detector.zip
  (GH-572) Fix: The handle is invalid - Output Redirection
  (maint) comments
  (GH-667) Provide How To Add Profile Manually
  (GH-667) PowerShell Custom Host - Set $Profile
  (GH-666) pass Write-ChocolateyError message param
  (GH-673) Ensure Get-BinRoot Warning is Shown
  (GH-666) setup logs colored write-host w/fallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants