我需要创建一个应用程序来从数据库中恢复用户的映射驱动器。为此,我需要创建一个脚本,该脚本将在登录时自动备份用户的映射驱动器。
这样做的最佳方法是什么?
You can write this backup to a text file using something like this:
@ECHO off
setlocal enabledelayedexpansion
type nul > C:\NetworkDriveList.txt
for /f "tokens=* delims= " %%a in ('net use') do (
set line=%%a
if "%line:~0,2%" == "OK" echo !line:~13,2! !line~23! & echo !line:~23!>> C:\NetworkDriveList.txt
)
This will create a txt file with the share paths in it for future reference should you need them again.