Solved using array in CMD

July 8, 2012 at 01:54:26
Specs: Windows 7
I want to run the below command, fo multiple accounts, if so collect them from the local users list.
If not then from a DOS variable >> SET USERS=bob,harry,james

net user <username> /active:no

How can i complete this?

See More: using array in CMD

Report •

July 8, 2012 at 22:09:19
Batch doesn't have associative arrays in the traditional sense of arrays. I have seen some implementations of doing it however.

What do you mean local users list? You mean enumerate them from the local SAM database or from a file containing usernames?

If you use a file you can do it like this. Create a text file with usernames one per line:

@echo off
for /f "tokens=*" %%i in (
) do (
net user %%i /active:no


Report •

July 8, 2012 at 22:38:36
✔ Best Answer
OR, If you want comma (or space) delimited var, f/e:
set users=absalom,melchizedech,Isaac

for %%i in (%users%) do net use %%i /active:no

Report •

July 10, 2012 at 00:55:35
Thanks, i will test both versions today if I get time.

Report •

Related Solutions

July 10, 2012 at 05:14:31
set users=absalom,melchizedech,Isaac

for %%i in (%users%) do net user %%i /active:no

Report •

Ask Question