I am looking to write a batch file that will take the usernames out of the directory "C:/Documents and Settings/****" and store them in environmental variables.
I then want to be able to then call each of these variables individually. For example I may want # 50 but not 39-43. I am designing the logic behind that but cannot get the variables to store the way I want. Any suggestions?
Dynamically assigned environmental variables
Moderator: DosItHelp
Re: Dynamically assigned environmental variables
Try this
Regards
aGerman
Code: Select all
@echo off &setlocal
pushd "C:\Documents and Settings"
for /f "delims=: tokens=1*" %%a in ('dir /ad /b^|findstr /n .') do set "userVar%%a=%%b"
popd
:: display all
set userVar
pause
Regards
aGerman
-
- Posts: 16
- Joined: 07 Jun 2010 10:27
Re: Dynamically assigned environmental variables
So this works to put each of the usernames into a variable. Now why can I not reference them.
For example I cannot "echo userVar7" and get the seventh entry.
For example I cannot "echo userVar7" and get the seventh entry.
-
- Posts: 16
- Joined: 07 Jun 2010 10:27
Re: Dynamically assigned environmental variables
DOH! I'm a butt. echo %userVar7%. All set here. You are wonderful. Thank you my german friend.
-
- Posts: 16
- Joined: 07 Jun 2010 10:27
Re: Dynamically assigned environmental variables
What about testing the variables dynamically. For example I am on a domain network. I am looking specifically to remove an icon that has been placed on individual users desktops. I do not really care about the administrator, localservice, setup etc... users. However some machines only have one user and some have hundreds. Any good way to do that?
Re: Dynamically assigned environmental variables
No, sorry. I've no idea how to do this remotely.
Regards
aGerman
Regards
aGerman