I have a problem with a laptop that, until I find a permanent fix, I have to keep deleting the credentials for automatic login as stored via the Windows Control Panel. I seem to accumulate these (up to 50 at a time) and they can only be deleted one at a time. This sounds like an ideal automation application for WinBatch. Question is - can I access these credentials directly via WinBatch? I don't really want to fire keystrokes at the window because this approach is so unpredictable.
Thanks
David
There are several potential ways to access Credential Manager from a WIL script.
- The cmdkey.exe command line utility. It has a delete option but you need to know the name of the credential to delete it. See WIL Run function.
- The Win32 API function CredDeleteA. See https://docs.microsoft.com/en-us/windows/desktop/api/WinCred/nf-wincred-creddeletea (https://docs.microsoft.com/en-us/windows/desktop/api/WinCred/nf-wincred-creddeletea) and the WIL DllCall function. You would need to use several API functions to fully implement a solution.
- Find an open source .Net assembly that covers the Win32 APIs. For example, https://www.nuget.org/packages/CredentialManagement (https://www.nuget.org/packages/CredentialManagement). It is source code only so you would have to create the assembly dll using the community version of Visual Studio.
Other forum members may have more and better ideas.