Solved

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

Posted on 2014-07-31
3
672 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

932 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

8 Experts available now in Live!

Get 1:1 Help Now