Solved

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

Posted on 2007-04-04
6
191 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:TinaSC
Comment Utility
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
Comment Utility
Wow - that's impressive. :^)

Thanx for the grade!
0
 

Author Comment

by:TinaSC
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

10 Experts available now in Live!

Get 1:1 Help Now