Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
batch file problem 5 67
Powershell File Sort 8 41
AWK: add from two digits (the month) within date string dd/mm/yyyy 2 18
AWK: digits < 10 add a zero how? 11 26
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
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 how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 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