How to programmatically add mapped network passwords (WinXP)?

In WinXP (SP2), you can store connected network passwords ...

Start-> Control Panel-> User Accounts-> Select one of them, then select "Manage My Network Passwords" from the related tasks.

I usually have about 25-30 servers mapped in this way with several different accounts / domains. The problem is that at some point during our policy updates they are erased, and this is the real PITA to add them back again.

Does anyone know how to add them programmatically using some kind of script?

Just to clarify, the ultimate goal is not to map drives, but to actually create records in this section. This allows us to use Windows authentication to connect to our servers (through Dameware, SSMS, etc.).

Addendum:

CredWrite mark brought me here ...

pinvoke.net - CredWrite (advapi32)

Which, in turn, brought me here ...

Peer Channel Blog - Application Password Security

Both were very helpful.

+2
source share
2 answers
  • cmdkey.exe is a version of the CLI tool, but I believe that it is only included in Win2003 +. I suspect that the copy on XP will work, but may violate your license agreement.
  • net use also has a savecred option if you map drives
  • , CredMgr . , :
    • % APPDATA%\Microsoft\Credentials\%UserSID%\Credentials
    • % USERPROFILE%\Local Settings\Application Data\Microsoft\Credentials\%UserSID%\Credentials
  • API , CredEnumerate - . :

: D'oh. PERSIST . :

  • CRED_PERSIST_SESSION: . . , .
  • CRED_PERSIST_LOCAL_MACHINE: . . ( , )
  • CRED_PERSIST_ENTERPRISE: . . , , , . , , . ( , AppData)

, CredWrite - API.

+3

NET USE () WshNetwork.MapNetworkDrive ( Windows scripting) - , .
, / , , , , .

+1

Source: https://habr.com/ru/post/1698993/


All Articles