Solved

Writing logon script to get user, computer, time, and date

Posted on 2007-04-04
6
192 Views
Last Modified: 2010-04-16
I posted this question not too long ago, but closed it because I thought I understood the answer.  I'm still missing something, so I'm re-asking it & have listed below what I've done.

Here's the script called logon.bat
echo %COMPUTERNAME%,%USERNAME%,%DATE%,%TIME% >> \\server\path\folder\\UserLogon.csv

I clicked on it from my desktop & from the server twice & got this csv file
server name                           myname      Tue 04/03/2007      5:31 PM
server name            myname      Tue 04/03/2007      5:32 PM
server name            Administrator      Wed 04/04/2007      10:06 AM
server name            Administrator      Wed 04/04/2007      10:07 AM

My question is getting this to run automatically.  I went to grp policy -> win settings -> scripts.  In the logon script, I added the logon.bat file.  Then I logged off, logged back on, & looked at the csv file.  My thinking is that it would run automatically (not needing to double click) but I didn't see a new line in the csv file.  Can someone help further?  I also need this for all users & it looks like it's only logging per machine???
0
Comment
Question by:TinaSC
  • 3
  • 3
6 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18850905
Are you in a domain?
You'd need to do this for logon scripts on your domain controller.

Otherwise, use scheduled tasks, if it's a single machine:

Start->Run->CMD /c schtasks /create /ru system /sc onlogon /tn logon /tr "c:\logon.bat" <Enter>

(change the location of logon.bat as needed).
0
 

Author Comment

by:TinaSC
ID: 18850931
I am in a domain.  I realize this may be an overly simplistic question, but bear with me.... Where in the domain controller do I put it?
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 250 total points
ID: 18850974
Open up ADUC (Active Directory Users and Computers) - right-click the domain name and choose properties.  You can then modify your default domain policy (or create a new one) and modify the same path (user config \windows settings\scripts\logon)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:TinaSC
ID: 18851203
Thanks sirbounty... easy enough.  I figure I'm not doing too bad since I had never even seen Windows Server until 6 months ago & didn't know there was such a thing as a logon script until a few weeks ago!!!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18851235
Wow - that's impressive. :^)

Thanx for the grade!
0
 

Author Comment

by:TinaSC
ID: 18854629
I know I closed this question, so I really hope you'll see this sirbounty.  The script worked, but only for my username?  It's in the logon/off scripts in the AD, but it's only showing my activity in the csv file.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now