Open Command Prompt
First you have to open a command prompt windows while you are logged into an administrator account. Press Windows + R to open the run dialog and then type “cmd“. (You can find out more shortcuts in – Keyboard shortcuts for Windows)
Using net user command
In the next step we will use the “net” command available only under command prompt for our purpose. The “net” command is one of the most powerful commands available on Windows. It lets you administer and automate many tasks in Windows. We will only use the sub-part specific to user account control. Here are some some details about the net user command (ignore this and skip tonext section to find out the our easy way):
Net user
Adds or modifies user accounts or displays user account information.
SYNTAX
net user [UserName [Password | *] [options]] [/domain]
net user [UserName {Password | *} /add [options] [/domain]]
net user [UserName [/delete] [/domain]]
PARAMETERS
UserName : Specifies the name of the user account to add, delete, modify, or view. The name of the user account can have as many as 20 characters.
Password : Assigns or changes a password for the user’s account. Type an asterisk (*) to produce a prompt for the password. The password is not displayed when you type it at the password prompt.
/domain : Performs the operation on the domain controller in the computer’s primary domain.
options : Specifies a command-line option. The following table lists valid command-line options that you can use.
You can read more about the command at Microsoft KB : Full options of net user command.
Using the Command
Do not get frightened by all those options. What we need to do is very simple. Just use
net user USER_NAME PASSWORD /times:Su-Sa,12-13;
net user USER_NAME PASSWORD /times:Su-Sa,3-15;Sa,15-16;
The first option restricts the time the user \”USERNAME\” with PASSWORD can log in from 12PM to 1PM on all days (Sunday through Saturday) (use 24 hour clock in the command its easier to read). The second command restricts the user USERNAME’s login time to 3AM to 3PM on all days and on Saturdays, allocates additional time from 3PM to 6PM.
In the above screen shot, the command is used to restrict the user “limited” to login only from 1PM to 3PM on all week days. The * will make the command prompt for the users password.
Clear all restrictions
To clear all restrictions just type : net user USER_NAME PASSWORD/*] /times:all
Here is a screen shot of the error produced if the user tries to log in during restricted hours.
This is a brief summary about the net user commands on Microsoft Knowledge Base :
Other notes
Days can be spelled out or abbreviated. Time can be given in increments of 1 hour. You may enter the time in either 12-hour or 24-hour notation. For 12-hour notation, use am, pm, a.m., or p.m. The time can be specified in increments of 1 hour. If you need to specify multiple times for different days you can use” /time:” option many times. If you give “*” instead of PASSWORD, a password prompt will be shown so as not to reveal the password.
No comments:
Post a Comment