Category filter
Script to set time limits on Windows devices
Configuring screen time limits on devices is a great way to restrict a user’s access to the device only during working hours. This also prevents performing any malicious activity after the allotted hours, even if the credentials of the user are compromised. Additionally, system updates can be conducted after work hours without the fear of losing user data. With Hexnode UEM, admins can remotely set time limits on multiple Windows devices by deploying Batch commands using the Execute Custom Script action.
Set screen time limit
1 |
net user <username> /times:<day>,<times> |
- Replace
<username>
with the name of the user account you want to limit. - Replace
<day>
with the specific day (e.g. Th) or multiple days (e.g. M-W) to apply the restriction, like Monday-Friday. You can use full names of the days or use the initials Su, M, T, W, Th, F, Sa. - Replace
<time>
with a 12-hour (e.g. 11am-4pm) or 24-hour (e.g. 10:00-17:00) time range. Do not add additional minutes to the times because you can only use them in one-hour increments.
Here are a few examples to better understand the different methods to set the time limits.
net user John /times:Th,11am-2pm
– This command allows the user to only log in between 11am to 2pm on every Thursday.net user John /times:M-F,10:00-17:00
– This command allows the user to log in between 10am to 5pm every day from Monday through Friday.
View set screen limits
1 |
net user <username> |
Execute the above command to see the details of the user account. The time limit information will be seen against the Logon hours allowed option.
For example: net user John
Reset to defaults
1 |
net user <username> /times:all |
To reset time limits to defaults, execute the above script by replacing the <username>
field with the username of the required account.
For example: net user John /times:all