Skip to content
⌘ NSIS Forum Archive

How to delete credential manager by NSIS?

8 posts

jack.nguyen#

How to delete credential manager by NSIS?

I want to know how to use NSIS script to remove credential manager data.

Could somebody help me?
Anders#
Maybe you could link to a page on MSDN so we can understand which credentials you are talking about...
jack.nguyen#
Originally Posted by Anders View Post
Maybe you could link to a page on MSDN so we can understand which credentials you are talking about...
Hello Anders,



I want to delete my credential data in Uninstall Section of NSIS script
Anders#
And which API did your application use to store the credential?


This might work but without knowing how you saved it, I can't be sure.

System::Call 'advapi32::CredDelete(t "crednamehere", i 1, i0)' 
jack.nguyen#
Originally Posted by Anders View Post
And which API did your application use to store the credential?


This might work but without knowing how you saved it, I can't be sure.

System::Call 'advapi32::CredDelete(t "crednamehere", i 1, i0)' 
Hello Anders,

Thanks for your help.

I develop an application using electron and use this library to save the credential data https://github.com/atom/node-keytar

Could I put your code in the NSI file? Is any plugin required here?
Anders#
The System plug-in is part of NSIS.

Replace crednamehere with "service/account" and those are the two parameters you used with keytar.
jack.nguyen#
It's work perfectly thanks very much!

But one more question could we remove all credentials with specific text

Ex: I have user1, user2, user3... and I want to remove all credentials start with 'user'
Anders#
!include LogicLib.nsh
Section 
System::Call 'ADVAPI32::CredEnumerate(t "user*", i0, *i0r1, *p0r2)i.r0'
${If} $0 <> 0
    ${IfThen} $1 U> 0 ${|} IntOp $1 $1 - 1 ${|}
    ${ForEach} $3 0 $1 + 1
        IntOp $4 $3 * ${NSIS_PTR_SIZE}
        System::Call '*$2(&i$4, p.r4)'
        System::Call '*$4(i, i.r5, p.r6)'
        System::Call 'ADVAPI32::CredDelete(t)(pr6, ir5, i0)'
    ${Next}
    System::Call 'ADVAPI32::CredFree(pr2)'
${EndIf}
SectionEnd