Solved

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

Posted on 2007-04-04
6
195 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
Technology Partners: 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

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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