Avatar of mguilmette
mguilmette asked on

Need to write a batch file that will set a variable based on user input

I am building a new 2000 Terminal Server and will be copying user accounts to the new server using ROBOCOPY.  The following command works, but I have to edit the user's name before I copy every account.  What I would like to do is have the batch file prompt me for the username and insert it into the batch file.

The following command copies the account from the old server (Z:) to the new server (C:).  It does not copy mp3 files and temp files/directories.

robocopy "Z:\Documents and Settings\jperkins" "C:\Documents and Settings\jperkins" /S /E /SEC /COPYALL /V /NP /LOG:"log.txt" /XF *.mp3 /XF *.tmp /XD *temp* /R:10 /W:30

Any help will be appreciated,
Mike
Windows BatchMicrosoft DOSWindows 2000

Avatar of undefined
Last Comment
mguilmette

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gastone Canali

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Gastone Canali

@echo off
setlocal
set /p user= enter username?
mkdir  "c:\Documents and Settings\%user%"
robocopy "Z:\Documents and Settings\%user%" C:\Documents and Settings\%user%" /S /E /SEC /COPYALL /V /NP /LOG:"log.txt" /XF *.mp3 /XF *.tmp /XD *temp* /R:10 /W:30
Gastone Canali

loss a "
@echo off
setlocal
set /p user= enter username?
mkdir  "c:\Documents and Settings\%user%"
robocopy "Z:\Documents and Settings\%user%" "C:\Documents and Settings\%user%" /S /E /SEC /COPYALL /V /NP /LOG:"log.txt" /XF *.mp3 /XF *.tmp /XD *temp* /R:10 /W:30 

Open in new window

ASKER
mguilmette

Thanks, your first solution is what I was looking for.  I posted below the working batch file for anyone else interested.


set /p user=enter username?
robocopy "Z:\Documents and Settings\%user%" "C:\Documents and Settings\%user%" /S /E /SEC /COPYALL /V /NP /LOG:"log.txt" /XF *.mp3 /XF *.tmp /XD *temp* /R:10 /W:30


Thank you for your help,
Mike
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck