Reputation: 25
environment windows domain prefer answer in way of a batch file
we are currently setting up 100+ new computers and i don't mind doing a loop and entering in the name of the computer each time, but i would LOVE to have a batch file i only have to type a few letters and BAM done.
see our naming scheme is something like: bar01, bar02, bar03 for the computers
here is what i would like to do: i have two variables to prompt the user. 1. computer name 2. number of computers
start a loop that will run the amount of times equal to the numbers of computers while also adding each of those numbers to the end of the computer name variable
(i know this likely isn't the correct syntax, but it is so i can, hopefully, show what i'm attempting to accomplish)
set /p cname=computer name:
set /p x=amount of computers:
for /l %%n in (1, 1,%x%) do {
xcopy "%~dp0Microsoft Word 2010.lnk" "\\%cname%%x%\c$\users\desktop\word.lnk"
}
i hope that is understandable, and i am not sure if the title is detailed enough?
Upvotes: 1
Views: 405
Reputation: 9545
Try like this :
@echo off
set /p cname=computer name:
set /p x=amount of computers:
for /l %%n in (1, 1,%x%) do (
echo %cname%%%n)
If you need the leading 0 (from 01 to 09) :
@echo off
set /p cname=computer name:
set /p x=amount of computers:
setlocal enabledelayedexpansion
for /l %%n in (1, 1,%x%) do (
set "$Nb=%%n"
if !$Nb! lss 10 set $Nb=0!$Nb!
echo %cname%!$Nb!)
Upvotes: 2