Solved

Batch file to install software for all users in a text file

Posted on 2014-07-31
3
671 Views
Last Modified: 2014-07-31
Need assistance with command syntax.
I am adding the domain username to a text file. For each of the usersnames in the text file, I want to run a command.

I am going to add this to a login script eventually.

I need it to operate as such:

If %username% == ( a name in user.txt) then run extra commands

I am attempting to get this working with a for loop on the names in the text file.

For %%i in my/users.txt do START /wait install.exe

all users who need the software will have their domain username in the txt file.

I an unable to get this working.
0
Comment
Question by:zequestioner
3 Comments
 
LVL 5

Expert Comment

by:amac81
ID: 40232364
You could add them all to a security group and then use 'ifmember' to make it work.  A for loop in this scenario sounds like the login could be slow as it loops through the list of names.
0
 
LVL 9

Expert Comment

by:David Carr
ID: 40232368
Use FOR /F %%i
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40232401
All you'll need is
find /i "%username%" \\server\share\user.txt  >nul && \\server\share\install.cmd

Open in new window

This will search the text file for the (exact, caseinsensitive) match of the current username, and if found execute the other batch (and not return to this batch).
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now