簡體   English   中英

在 Windows 7 中識別映射驅動器的 ip 並重新連接它

[英]In Windows 7 identify ip of a mapped drive and reconnect it

我知道我可以使用 windows 7 顯示映射的驅動器

c:\.net use

它顯示

Status       Local     Remote                    Network
-------------------------------------------------------------------------------
OK           X:        \\192.168.168.100\c\Output
                                            Microsoft Windows Network
OK           Y:        \\192.168.168.100\c\Input
                                            Microsoft Windows Network

是否可以發現 X(或 Y)是否連接到 ip 192.168.168.100? 在這種情況下使用斷開它們

net use X: /delete
net use Y: /delete

並使用(從 192.168.168.100 到 192.168.168.101)將它們重新連接到相同的路徑但不同的 ip

net use X: \\192.168.168.101\c\Output /user:user01
net use Y: \\192.168.168.101\c\Input  /user:user01

反之亦然,如果它們連接到 192.168.168.101,請斷開連接並重新連接到 192.168.168.100

有人可以幫我解析 .net 使用 output 嗎?

不漂亮,但在我的有限測試中有效:

@echo OFF
setlocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
goto start

:checkone
setlocal
echo INFO: %3 is mapped to drive %2
set "server="&set "new="
for /F "usebackq tokens=1,* delims=\" %%A in ('%3') do @set server=%%A&set share=%%B
if "%server%"=="192.168.168.100" set new=192.168.168.101
if "%server%"=="192.168.168.101" set new=192.168.168.100
if not ".%new%"=="." (
    call net use %2 /delete
    call net use %2 \\%new%\%share% /user:user01
)
endlocal
@goto :EOF

:start
for /F "tokens=*" %%A in ('net use^|find ":"^|find "\\"') do @for /F "usebackq tokens=1,* delims=:" %%B in ('.%%A') do call :checkone %%B: %%C

如果遠程路徑有空格,可能會有麻煩......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM