![]() |
|
|
|||||||
| Petri.co.il is happy to award auglan the title of Most Valuable Member !!! |
| Register | Calendar |
Search |
Today's Posts |
Mark Forums Read |
| Notices |
|
|
Batch to log Username, Time and Ip-address at login [was: Batch file help]this thread has 2 replies and has been viewed 5330 times
|
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
I need to be able to log - Username, time and Ip address at login via a batch file. Can anyone help?
|
|
#2
|
||||||||||
|
||||||||||
|
You don't mention your Operating System...
%username% %time%, time.exe or now.exe from the Resource Kit Extract the required data from the output of ipconfig http://www.ericphelps.com/batch/samples/ip.txt All of which could have been found within 5 seconds by searching this site and/or Google
__________________
Gareth Howells BSc (Hons), MBCS, MCP, MCDST, ICCE Any advice is given in good faith and without warranty. Please give reputation points if somebody has helped you. "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb. "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three. |
|
#3
|
||||||||||
|
||||||||||
|
@tssizemore82,
In order to keep the forums running well, please follow these simple rules for the forums here. Search before you post. And, carefully write your question, provide all the necessary information. Are the computers client in a domain?? Are the users domain users??? OSs? IP version? You like to run the batch as logonscript? using GPOs?? Is there a networkshare to write the logs to?? Several batch samples can be found already in this scripting forum! sample: Code:
@echo off & cls
Set "logFile=%Computername%.log" provide full networkpath to logfile!
::# Get IP Address
for /f "skip=1 tokens=2 delims=[]" %%* in (
'ping.exe -n 1 %Computername%') Do (set "IP=%%*" & goto:exitFor1)
:exitFor1
::# Get Full Name of User
If /i "%USERDOMAIN%"=="%Computername%" (
for /f "skip=1 tokens=2,* delims= " %%a in (
'net.exe user "%Username%"') do (
(set "DisplayName=%%b" & goto:exitFor2))
) Else (
for /f "skip=3 tokens=2,* delims= " %%a in (
'net.exe user "%Username%" /domain') do (
(set "DisplayName=%%b" & goto:exitFor2))
)
:exitFor2
If defined DisplayName Set "DisplayName=%DisplayName:)=^)%"
::# Append to log
>>"%logFile%" (
echo\*** Logon
echo\User : %USERDOMAIN%\%Username% (%DisplayName%^)
echo\Date/Time : %date% - %time%
echo\To computer: %IP% (%Computername%^)
echo\-----------------------------------------------------------------)
__________________
This posting is provided "AS IS" with no warranties, and confers no rights. __________________ ** Remember to give credit where credit's due ** and leave Reputation Points for meaningful posts |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| batch animation (was:Batch file problem thing) | iamgod | General Scripting | 3 | 1st June 2009 18:37 |
| Network Log Batch File | kio | Windows 2000 Pro, XP Pro | 10 | 28th April 2009 20:29 |
| how to create batch file for user login information | bhanuk | General Scripting | 6 | 9th January 2009 02:55 |
| Creating a Batch file for Reg add Entries and File Coping | adainty | Windows 2000 Pro, XP Pro | 3 | 19th January 2008 22:16 |
| Batch file at login | Broodgeneral | General Scripting | 5 | 23rd March 2007 15:04 |