我的目的是得到这个......
cls
setlocal enableextensions disabledelayedexpansion
echo Create backup txt file of mapped drives
echo -----
set /p PCname=Asset tag or IP address:
set /p UserID=UserID:
for /f "tokens=2,3 delims=," %%a in (
'wmic netuse get LocalName^, RemoteName^, Status /format:list ^| find ":"'
) do echo(%%a %%b>> \\%PCname%\c$\windows\temp\%PCname%_%UserID%_map.txt
xcopy /d/y \\%PCname%\c$\windows\temp\%PCname%_%UserID%_map.txt ".\remoteStats\"
pause
Goto :mdmenu
将远程PC的驱动器%PCname%
映射到只包含驱动器号和路径的文本文件,将该文本文件复制到运行该脚本的技术计算机上。\ _dotestats \ folder
这样我可以使用相同的文本文件自动重新映射这些驱动器
:mdrestore
cls
echo Map Drives from backup txt
echo -----
echo Notes:
echo Needs a backup to restore from, inside
echo remoteStats folder
echo.
set /p PCname=Asset tag or IP address:
set /p UserID=Enter BH Username:
for /f %%a in (.\RemoteStats\%PCname%_%username%_map.txt) do Psexec \\%PCname% -d -s cmd /c net use %%a /p:Yes
psexec \\%PCname% -d cmd.exe /c net use S: \\mapped.drive\share /p:Yes
psexec \\%PCname% -d cmd.exe /c net use H: \\mappeddrive2\home /p:Yes
Print "Drives mapped"
Timeout /t 30 >nul
GOTO :mdmenu