Old 17th August 2022, 07:03   #1
jack.nguyen
Junior Member
 
Join Date: Aug 2022
Posts: 4
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?
jack.nguyen is offline   Reply With Quote
Old 17th August 2022, 10:05   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,531
Maybe you could link to a page on MSDN so we can understand which credentials you are talking about...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th August 2022, 06:46   #3
jack.nguyen
Junior Member
 
Join Date: Aug 2022
Posts: 4
Quote:
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,

https://support.microsoft.com/en-gb/...1-fc16e8165ac0

I want to delete my credential data in Uninstall Section of NSIS script
jack.nguyen is offline   Reply With Quote
Old 19th August 2022, 08:33   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,531
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
Anders is offline   Reply With Quote
Old 19th August 2022, 09:08   #5
jack.nguyen
Junior Member
 
Join Date: Aug 2022
Posts: 4
Quote:
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?
jack.nguyen is offline   Reply With Quote
Old 19th August 2022, 10:50   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,531
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
Anders is offline   Reply With Quote
Old 19th August 2022, 11:01   #7
jack.nguyen
Junior Member
 
Join Date: Aug 2022
Posts: 4
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'
jack.nguyen is offline   Reply With Quote
Old 19th August 2022, 13:08   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,531
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
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
credential manager

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump