本地-bat-连接凭据管理器

📅 发布时间:2026/8/28 7:20:53
本地-bat-连接凭据管理器
以下是如何删除凭据管理器以及新增凭据管理器echo off chcp 65001 nul setlocal enabledelayedexpansion net use * /delete /y nul 21 for /f skip3 tokens2 delims: %%a in (cmdkey /list) do ( set credname%%a set credname!credname: ! cmdkey /delete:!credname! nul 21 ) :: 3. 添加目标服务器凭据 cmdkey /add:192.168.xx.xx /user:ccrc /pass:2026 cmdkey /add:192.168.xx.xx /user:Administrator /pass:2016 echo 两台主机凭据已全部写入 :: 先尝试连接 192.168.xx.xx :RETRY24 echo 正在尝试连接 \\192.168.xx.xx net use \\192.168.xx.xx /persistent:yes nul 21 if %errorlevel% equ 0 ( echo ✅ \\192.168.xx.xx 连接成功 explorer \\192.168.xx.xx goto TRY65 ) echo ❌ \\192.168.xx.xx 连接失败5秒后重试... timeout /t 5 /nobreak nul goto RETRY24 :: 再尝试连接 192.168.xx.xx :TRY65 :RETRY65 echo. echo 正在尝试连接 \\192.168.xx.xx net use \\192.168.xx.xx /persistent:yes nul 21 if %errorlevel% equ 0 ( echo ✅ \\192.168.xx.xx1 连接成功 explorer \\192.168.xx.xx exit ) echo ❌ \\192.168.xx.xx 连接失败5秒后重试... timeout /t 5 /nobreak nul goto RETRY65