1.

Solve : Can FOR command use with range??

Answer»

Hi,

Is it possible to use FOR command with range SELECTION

-  I have computer names range from A001 to A0010 and B001 to B0020.

-  If computer name is between A001 to A0010, it will SET the computer with autologin account A and autologin account B for range between B001 to B0020.

Thanks.   Yes this is possible. Please DESCRIBE your requirement more fully.
I am building PC image and setup login script that check computer name (%COMPUTERNAME%) and setup the autologin account based on the computer name.  The computer name will be within specified range such as from a001 to a005 and b001 to b0010. 

I think something like:

FOR /F %COMPUTERNAME% SET AUTOLOGIN-A

I just don't know how to use FOR command with range.  I probably can use FOR with GOTO but I don't WANT to type all computer names.  I read that FOR command can use token range but there is limitation of having only 26 lines?

Thanks for your help.

please describe example of a computer name and desired autologin name for that computer name.workstation computer name group:

W00001
W00002
W00003

it will set with autologin account:  C-A-WKS

laptop computer name group:

L00001
L00002
L00003

it will set with autologin account: C-A-LTP
What about the numbers?Do you mean the computer numbers?  the number will be INCREMENT by 1 for each group so for workstation group number will be W00001, W00002, W00003 up to W00020 while for laptop will be L00001, L00002 up to L00010. Code: [Select]echo off
setlocal enabledelayedexpansion
for %%a in ( W L ) do (
   for /L %%b in (1,1,10) do (
   if %%b gtr 9 (set pot=000) else (set pot=0000)
      if %%a equ W (%%a!pot!%%b C-A-WKS***) else (%%a!pot!%%b C-A-LTP***)
))


***dunno about autologin command

dunno if this will work



Discussion

No Comment Found