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.

Disclaimer:

The Sample Scripts provided below are adapted from third-party Open-Source sites.

Set screen time limit

  • 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.
Note:

If the command is run with the <days> and <time> fields blank, the target user will be logged out of the account indefinitely.

View set screen limits

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

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

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository