Petri IT Knowledgebase Forums
 

Petri.co.il forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Windows Scripting > General Scripting
Petri.co.il is happy to award auglan the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read

Notices

Batch to log Username, Time and Ip-address at login [was: Batch file help]

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

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10th August 2009, 21:56
tssizemore82 tssizemore82 is offline
Casual
Casual
 
 Join Date: Jul 2008
  6 month star 12 month star
 Posts: 32
 Reputation: tssizemore82 is on a distinguished road (10)
Default Batch to log Username, Time and Ip-address at login [was: Batch file help]

I need to be able to log - Username, time and Ip address at login via a batch file. Can anyone help?
  #2  
Old 10th August 2009, 22:10
gforceindustries's Avatar
gforceindustries gforceindustries is offline
Senior Member
Wrote the book
 
 Join Date: Sep 2008
  6 month star 12 month star
 Location: Leics, UK
 Posts: 4,342
 Reputation: gforceindustries is a jewel in the roughgforceindustries is a jewel in the roughgforceindustries is a jewel in the roughgforceindustries is a jewel in the rough (305)
Default Re: Batch file help

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  
Old 11th August 2009, 01:44
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,267
 Reputation: Rems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to behold (903)
Default Re: Batch file help

@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\-----------------------------------------------------------------)
\Rems
__________________

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
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT +3. The time now is 17:40.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri