Announcement

Collapse
No announcement yet.

How to delete credential manager by NSIS?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    Maybe you could link to a page on MSDN so we can understand which credentials you are talking about...
    IntOp $PostCount $PostCount + 1

    Comment


    • #3
      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

      Comment


      • #4
        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.

        PHP Code:
        System::Call 'advapi32::CredDelete(t "crednamehere", i 1, i0)' 
        IntOp $PostCount $PostCount + 1

        Comment


        • #5
          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.

          PHP Code:
          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?

          Comment


          • #6
            The System plug-in is part of NSIS.

            Replace crednamehere with "service/account" and those are the two parameters you used with keytar.
            IntOp $PostCount $PostCount + 1

            Comment


            • #7
              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'

              Comment


              • #8
                PHP Code:
                !include LogicLib.nsh
                Section 
                System
                ::Call 'ADVAPI32::CredEnumerate(t "user*", i0, *i0r1, *p0r2)i.r0'
                ${If} $<> 0
                    
                ${IfThen} $1 U${|} IntOp $$${|}
                    ${ForEach} $
                3 0 $1
                        IntOp 
                $$* ${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 
                IntOp $PostCount $PostCount + 1

                Comment

                Working...
                X