?
Solved

Need a simple batch file that will capture a username and computername

Posted on 2006-04-28
8
Medium Priority
?
1,521 Views
Last Modified: 2008-02-01
No one has kept track of user to workstation name and now I have to figure out a way to get it. We have many different reasons why we need this but I would like to know the best way to capture this when users logon to the network.
A simple Set command will display what I am looking for but I would like to know the best way to capture this info and pipe it to file on a network share. Hope someone can help.

Thanks
0
Comment
Question by:mikedotm
8 Comments
 
LVL 30

Assisted Solution

by:SteveGTR
SteveGTR earned 300 total points
ID: 16565487
You could create a batch file that is called from some network login script. It would look something like this:

@echo off

setlocal

set networkShare=\\yournetwork\sharename\Common directory\logfile.txt

(echo --------------------)>>"%networkShare%"
(echo Login time: %date% %time%)>>"%networkShare%"
(echo Username: %username%)>>"%networkShare%"
(echo Computername: %computername%)>>"%networkShare%"
(echo --------------------)>>"%networkShare%"

You could include other information. Type:

set

at the command prompt to see other information that might be useful. You'll want to adjust the networkShare environment variable to a network share and directory that is available to all users.

Good Luck,
Steve
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 900 total points
ID: 16565504
Add this to your login scripts:

echo %computername%,%username%,%date%,%time% >> \\server\share\info\%computer%.txt
echo %computername%,%username%,%date%,%time% >> \\server\share\info\%username%.txt

and give the users some write tights to the \\server\share share and info directory under it... or wherever you want to put it.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16565508
Doh, took me three mins to read and type that then :-)

Steve
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 43

Expert Comment

by:Steve Knight
ID: 16565522
My suggestion creates one file for each user and computer which can be useful -- i.e. see which computers a user logs into and which users login to a computer.   If your names collide on these or you want to keep them seperate create a different directory for users and computers.

Steve
0
 
LVL 12

Assisted Solution

by:AmigoJack
AmigoJack earned 150 total points
ID: 16594440
in case %computername% is not set, there exists also an exe you can call to get that:

hostname
0
 
LVL 1

Assisted Solution

by:boris711
boris711 earned 150 total points
ID: 16601968
I understand that this is under the DOS heading, but I think you might find Windows Script Host would be well suited to your needs.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16615546
I hate B grades :-(
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 16615561
Poor grading Mike... Good that we all got assists, but grading as a B is not the way to get help here on EE. Especially since you elected not to participate in the solution to your problem. You gave little direction in what you wanted and we all responded the best we could. Please consider this the next time you ask for help on EE. Thanks :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question