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

Posted on 2007-04-04
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???
Question by:TinaSC
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 67

Expert Comment

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).

Author Comment

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?
LVL 67

Accepted Solution

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)
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

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!!!
LVL 67

Expert Comment

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

Thanx for the grade!

Author Comment

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.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

631 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