1,050 pts.
 How do I echo a “y” choice in this bat file?
I have the following bat file. I did not create it, but got it off of the MS scripting site. We are going to migrate data from an old nt server to a new server. The company has been using this server for about 10 years and everybody has one or more drives mapped to it. This file re-maps the users current drives to the new server correctly. However in testing it out, on some users, for some reason the file will stop and because of "open files or incomplete searches pending" it will ask for a y/n input form the users. Is there anyone who can see where I should put the echo y| in the file so it will just disconnect/re-map that drive and continue running? we have a vbs script that will re-direct all the shortcuts and links to the new path, but this has to run first. +++++++++++++BAT FILE START+++++++++++++++++++++++ @echo off echo /y set OldName=\old_server set NewName=\new_server net use | find /i "%OldName%" > nul || goto :eof for /F "tokens=2-3" %%a in ('net use ^| find "\"') do call :Sub %%a %%b echo /y goto :eof :Sub set DriveLetter=%1 if %DriveLetter:~1,1%==: goto Letter :NoLetter set ShareName=%1 call set ShareName=%%ShareName:%OldName%=%NewName%%% net use %1 /d net use net use %ShareName% net use goto :eof :Letter set ShareName=%2 call set ShareName=%%ShareName:%OldName%=%NewName%%% @echo on net use %DriveLetter% /d net use net use %DriveLetter% %ShareName% net use @echo off ++++++++++++++++++++END OF BAT FILE++++++++++++++++

Software/Hardware used:
xp pro sp3. 2003 server dc
ASKED: July 15, 2010  6:34 PM
UPDATED: August 16, 2010  4:09 PM

Answer Wiki:
Your script cleaned up a bit with force disconnect on NET USE. <pre>@echo off ECHO Starting script set OldName=\old_server set NewName=\new_server net use | findst /i "%OldName%" > nul If "%ErrorLevel%"=="0" GOTO :DONE for /F "tokens=2-3" %%a in ('net use ^| find ""') do call :Sub %%a %%b goto :DONE :Sub set DriveLetter=%1 if %DriveLetter:~1,1%==: goto :Letter :NoLetter set ShareName=%1 set ShareName=%%ShareName:%OldName%=%NewName%%% net use %1 /d /yes net use %ShareName% goto :eof :Letter set ShareName=%2 set ShareName=%%ShareName:%OldName%=%NewName%%% @echo on net use %DriveLetter% /d /yes net use %DriveLetter% %ShareName% @echo off goto :eof :DONE ECHO Completed script </pre>
Last Wiki Answer Submitted:  July 16, 2010  5:08 pm  by  Pjb0222   3,310 pts.
All Answer Wiki Contributors:  Pjb0222   3,310 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Thank you.
Sorry for not seeing it sooner, this project got pushed over to the side. But now it’s back.
I’ll give it a go.

 1,050 pts.