Page 1 of 1

Last logon

Posted: 25 Apr 2010 07:18
by alcool9999
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.

Re: Last logon

Posted: 25 Apr 2010 08:32
by aGerman
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