docs icon indicating copy to clipboard operation
docs copied to clipboard

Update uninstall script for fix PATH clean failure

Open knokmki612 opened this issue 3 years ago • 2 comments

Faced an error when execute uninstall script which documented. See below (note to I use windows 10 in Japanese locale):

PS C:\Users\kimiaki\Desktop> .\uninstall.ps1
詳細: Chocolatey Install location found in Machine Path. Removing...
警告:     This could cause issues after reboot where nothing is found if something goes wrong.
    In that case, look at the backup file for the original PATH values in 'C:\PATH_backups_ChocolateyUninstall.txt'.
"3" 個の引数を指定して "SetValue" を呼び出し中に例外が発生しました: "レジストリ キーに書き込めません。"
発生場所 C:\Users\kimiaki\Desktop\uninstall.ps1:71 文字:5
+     $machineKey.SetValue('PATH', $newMachinePATH, 'ExpandString')
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : UnauthorizedAccessException

This caused by SetValue needs write permission but $machineKey haven't the permission. To solve, add writable option when use OpenSubKey. See: https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registrykey.opensubkey?view=windowsdesktop-5.0#Microsoft_Win32_RegistryKey_OpenSubKey_System_String_System_Boolean_

knokmki612 avatar Sep 04 '21 16:09 knokmki612

@JPRuskin Could you confirm these steps?

pauby avatar Nov 11 '21 19:11 pauby

@JPRuskin did you see the above request?

gep13 avatar Sep 05 '22 13:09 gep13

Thanks for the contribution here! We had a follow up PR to fix this along with the other OpenSubKey() call in this script as well, so this change has already been made. This was done in #600.

Closing this out for now, but thank you for the PR nonetheless!

vexx32 avatar Dec 16 '22 16:12 vexx32

I apologize for neglecting this PR, and thank you for your kindly response.

knokmki612 avatar Dec 16 '22 18:12 knokmki612