Computing.Net > Forums > Programming > Newbie creating a batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Newbie creating a batch file

Reply to Message Icon

Name: davidvoyage
Date: July 14, 2008 at 13:05:32 Pacific
OS: WIndows NT
CPU/Ram: Intel
Comment:

Hi,

FYI, I have a txt file(abc.txt) that contains a column of logon names.
I need to create a batch file that read that file and then for each of the name run this command:
"net user [logon names] |find /i "last logon" ". And then output the logon name and the result to another txt file.

How to do it? Thx



Sponsored Link
Ads by Google

Response Number 1
Name: davidvoyage
Date: July 14, 2008 at 13:12:49 Pacific
Reply:

FYI, I'm using Windows NT.


0

Response Number 2
Name: Razor2.3
Date: July 14, 2008 at 17:23:37 Pacific
Reply:

Use the FOR command.

FOR /F %a IN (abc.txt) DO net user %a |find /i "last logon" >> another.txt


0

Response Number 3
Name: davidvoyage
Date: July 15, 2008 at 06:29:15 Pacific
Reply:

Thx, it works for one command only. but is it possible to do TWO COMMANDS for each line?

I tried:
FOR /F %%a IN (abc.txt) DO net user %a |find /i "user name" DO net user %a |find /i "last logon" >> another.txt

but it doesn't work.


0

Response Number 4
Name: Mechanix2Go
Date: July 16, 2008 at 00:11:22 Pacific
Reply:

for /f "tokens=* delims= " %%b in (my.txt) do (
firstop %%b
nextop %%b
and so on
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Newbie creating a batch file

Create a batch file to rename text www.computing.net/answers/programming/create-a-batch-file-to-rename-text/14900.html

Help for create a batch file www.computing.net/answers/programming/help-for-create-a-batch-file/15796.html

Creat a Batch file to zip files www.computing.net/answers/programming/creat-a-batch-file-to-zip-files-/17644.html