简体   繁体   中英

Batch file to change all network shares on computer

I need to change all shares of //foo to //bar in a batch file. Say i have R: //foo/foo and Z: //foo/bar

I need to have a batch script that makes them R: //bar/foo and Z: //bar/bar

Anyone have any idea how to do this? I'm thinking of looping through somehow with net use but that's as far as I've come. Will be researching myself as well but thought I'd post here and see if somebody knew real quick as I'm in a bit of a crunch.

Thanks for you help.

This is for Windows XP Zachary

remap.bat

@ECHO OFF

IF "%1"=="" echo usage: remap oldserver newserver & goto :EOF
SETLOCAL ENABLEDELAYEDEXPANSION

for /f "tokens=2,3 delims= " %%a in ('net use ^| FIND /I "%1"') do (
   Set SHARE=%%b
   Set SHARE=!SHARE:%1=%2!
   net use /delete /y %%a
   net use /persistent:yes %%a !SHARE!
)

hope this helps, adopt the persistent:yes to your needs!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM