How do I echo a “y” choice in this bat file?

1050 pts.
Tags:
.bat file
Domain Controller
ECHO
Microsoft Windows Server 2003
Microsoft Windows XP
Windows Server 2003 Domain Controller
Windows XP SP3
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • swinehart6803
    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 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following