Change Date & Time on PC Joined to Domain
Network administrators can get some strange requests from users. If you're here at this page, you've probably received this strange request too or maybe you have a need to change the date on your workstation that's joined to a domain network. Under normal circumstances, all computers that are joined to a domain will synchronize their time with a domain controller. It's important for all members of a domain to maintain an accurate system time configuration with the domain controller. Otherwise the workstation will experience trouble with the Kerberos tickets that relate to authentication within the domain. Due to this importance, a domain joined computer will restrict access to setting a custom date and time on the workstation. Even when the user has local administrative rights to the computer.
So why would one need to do such as thing? This request came about from a local municipality. Their tax collection software makes use of the system time on the workstation as a timestamp in the application for when a late penalty should be applied to a transaction. It just so happened that the last day of the month had fallen on a weekend. Meaning that when the office returned on Monday, it was the start of a new month. The request to change the date was for the purposes of entering a payment that was received on the prior Friday. So that it wouldn't apply the penalty that began on Monday.
This guide will show you how to make use of a batch file script to temporarily change the date on a workstation for a short time. Allowing for such tasks to be completed before reverting back to the proper synchronization with the domain controller.
Step 1: A prerequisite and a word of caution
There's one prerequisite that needs to be met in order for this batch file script to be used. The user running the script will need to do so with administrative rights. So the user will need to either have local administrative rights to the workstation that they're running this script on or they would need to know a username and password for an account that does have administrative rights to the workstation. So that they may enter it in the UAC prompt that appears when they attempt to run the batch file as an administrator.
We must also stress the important role that an accurate time plays in a domain. As mentioned above, Kerberos tickets rely heavily on time synchronization with the domain controller. This script will prompt the user to enter a desired date and then pause after it makes the changes to the system time. The user should then, at that moment and without delay, perform the tasks that require the updated system time. Then return to the batch script to continue with the rest of the processing. Which entails registering the time services and registration with the domain controller. If the user fails to complete this process, authentication errors are likely to occur that will result in trouble logging in or accessing files and services.
Step 2: Create the batch file and make it available to the user
To create the batch file script, open Notepad and paste the contents listed below into the application. Save this file to the user's desktop as a .BAT file. This is easily done by using double quotes in the file name when saving this file. Such as "changedate.bat" with the double quotes included as shown.
@echo OFF
@title Change Date
echo.
echo Enter date in the following format. Example: 1/15/2020
echo.
set /P var=Enter date:
w32tm /unregister
date %var%
cls
echo.
echo WARNING: DO NOT CLOSE THIS WINDOW!
echo.
echo The inputted date should now be in effect! Please complete desired tasks before continuing.
echo.
echo You MUST return to this window and press any key when finished!
echo.
pause
net stop w32time
w32tm /register
net start w32time
w32tm /resync
exit
The user should now have this file available to them on their desktop. To utilize this script, they should perform the following steps that are listed below:
- Right click the batch file and select "Run as Administrator."
- Enter a new date in the DOS window that appears when prompted and press Enter.
- Minimize the DOS window and complete the task that requires the new time. Do not close the DOS window.
- Return to the DOS window and press any key to continue. The batch file will complete the pending tasks to revert the time and close the DOS window automatically.