We are running MS Server 2003. We have written a program in VB to record the user name and time in and out of the lab to track computer usage. These are users in our domain. I am having trouble running the files from the group policy. If I read correctly you must use either a .bat file or a windows scripting file to use the group policy settings to run a program on logon and logoff. I tried a bat file calling the logon.exe file. Doesn't work. I tried calling the logon.exe directly. Doesn't work.

I can run the logon file locally by calling a .bat file. But I cannot figure out how to call the logoff file. What can I use to trigger the logoff file to execute? Both files are writing to a database on the network.

I am not familiar with windows scripting files. Should I try to covert to script to call the files?

Any information could be helpful. Am under a time constraint of course!

Thanks,
M. Teeters

Dani AI

Generated

A short, practical summary and next steps based on the thread from and .

Group Policy user logon/logoff is the supported way to run per-user programs in a Windows Server 2003 domain (User Configuration → Windows Settings → Scripts (Logon/Logoff)). Those scripts execute in the interactive user context and the script files for a GPO live in the SYSVOL area (use the GPO editor’s "Show Files" to place them). The Security event log also records logon/logoff events, but extracting reliable per-session totals from raw event logs is fiddly (IDs and behavior vary by OS and shutdown may not always produce a logoff event). (learn.microsoft.com)

Practical checklist (worked-for-others, and a simple sample):

  • Put the script into the GPO via "Show Files" so it replicates to SYSVOL.
  • Prefer UNC paths (\server\share) rather than mapped drive letters when the script touches network resources.
  • If the DB/share requires a mapped drive, map it first in the same script then call the recorder and remove the mapping when finished.
  • Avoid embedding plain-text credentials in scripts; use integrated auth or a service account where possible.

Example logon.bat:

@echo off
net use \\dbserver\share /persistent:no >nul 2>&1
start /wait "" "\\fileserver\apps\LogonRecorder.exe" "%USERNAME%" "%COMPUTERNAME%"
net use \\dbserver\share /delete >nul 2>&1

Putting the mapping and the recorder call in one script forces the order and usually fixes the "works locally but not from GPO" symptom. (us.informatiweb-pro.net)

Why logoff scripts sometimes fail and better alternatives:

  • Group Policy scripts can be skipped or fail when the network is unavailable or when "slow link" detection suppresses script processing; the network can also be torn down during logoff/shutdown. Adjusting the "Always wait for the network at computer startup and logon" / slow-link settings helps, but is not bulletproof. (ftp.zx.net.nz)

For a robust, long-term solution in a lab where accurate start/stop times matter, register a central process instead of relying solely on logoff scripts: a Windows service (or a background app) that handles session-change notifications (SERVICE_CONTROL_SESSIONCHANGE / OnSessionChange, or WTS session APIs / SENS) can record logon and logoff reliably and run under a service account with appropriate DB permissions. That approach avoids race conditions with network teardown and works even when users disconnect unexpectedly. (stackoverflow.com)

Troubleshooting tips: check the GPO’s script folder in SYSVOL, verify NTFS/share permissions for the script and DB share, enable Group Policy client logging on a test workstation, and watch Userenv/Group Policy events plus the Security log for related failures.

Recommended Answers

All 5 Replies

Doesn't Windows already log this information?

I'm not sure. If it does, I don't know how to access it. You can look at the event logs and see when a successful or unsuccessful log on happens, but when you try to track a specific user through the event logs, it gets to be a very time consuming and difficult job.

I put the .exe in a bat file and it works, for the logon (when I install the program on the local workstations), but I can't seem to trigger the logoff program. I'm not opposed to reading. I know some solutions aren't easy and have many ways to solve.

Thank you for your reply.

M.Teeters

I gotcha. Unfortunately, I can't help ya - I don't know much about Windows servers.

Thank you for replying anyway. Maybe someone will be able to offer some suggestions.

M.Teeters

I finally got the logon and logoff files to work. I had to do it through group policy. I found out you can run more than one file, so I ran a .bat file that maps the network drives first. I had to have connection before it would write to the database on one of the app servers. I also found out that any executable file will work. It doesn't have to be a script file. So, now we can see the user, the time in, time out, and total time spent logged in. Since we are a school, this helps to justify additional personnel and equipment.

Thanks to Ooble for your response, and by the way, I like your program!
M.Teeters

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.