Last logon

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alcool9999
Posts: 4
Joined: 17 Sep 2009 09:05

Last logon

#1 Post by alcool9999 » 25 Apr 2010 07:18

ok this is my code so far

@echo off
echo enter user:
set /p user=
net user %user%
pause

now i need to copy the line that says last logon. this line comes up when you do the net user command.

i used to know how to do this but ive forgot. i think it invloved using the copy command of some sort.

copy.....net user. i really dont know please help thanks.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Last logon

#2 Post by aGerman » 25 Apr 2010 08:32

You could use a FOR /F loop.

Code: Select all

@echo off
set /p "user=enter user: "
for /f "delims=" %%a in ('net user %user%^|findstr /i /c:"last logon"') do set "lineLastLogon=%%a"

:: your stuff here, eg.:
echo %lineLastLogon%

pause


Regards
aGerman

Post Reply