Hack Forums
[Release] Set Logon Time Limits For Any Account in Windows - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Release] Set Logon Time Limits For Any Account in Windows (/showthread.php?tid=6270101)



Set Logon Time Limits For Any Account in Windows - Emre_ - May 2, 2024

Hi HF Members,

With this batch script, a logon time limit can be set for any Windows operating system user account.

Code
:: Set Logon Time Limits For Any Account in Windows


@Echo Off

Cls & Color 0E



(Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)

Cls



:UserName

Echo.
Echo            Specify the UserName that you want to limit  
Echo.
Echo.
Set /p "User=:^> "
Cls
if ["%User%"]==[] Goto :UserName


:_CHOICE

Cls & Mode CON  LINES=11 COLS=80 & Color 0E & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo        1 - Do You Want to Set Time Limit for the User Account: "%User%"    
Echo.      
Echo        2 - Allow the "%User%" Access at all Times.
Echo.


Set /p input=:^>

If Not %input%==1 (Goto :_Ex) Else (Goto :_Enable)

:_Ex
If Not %input%==2  (Goto :_CHOICE) Else (Goto :_Disable)



:_Enable
Cls & Mode CON  LINES=11 COLS=140 & Color 0E & Title Created By FreeBooter
Cls
Echo.
Echo            Specify the times that users are allowed to use the computer.
Echo            You can use 12-hour or 24-hour notation for hours.
Echo            If you use 12-hour notation, use AM and PM, or A.M. and P.M.
Echo            You can use any of these time range using either a 12-hour (3am, 1pm, etc.) or 24-hour (03:00, 13:00, etc.) format.
Echo            You can only use times in one-hour increments, so don't add any minutes to the times.
Echo.
Echo            Type Logoff Hour
Echo.
Set /p Start=:^>
Cls
Echo.
Echo            Type Login Hour
Echo.
Set /p Login=:^>


Net user "%User%" /times:M-Su,%Start%-%Login%



Cls & Mode CON  LINES=11 COLS=60 & Color 0E & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo.
Echo          Denying User Account "%User%" Access to Windows    
Echo.
Echo.
Echo.
Ping -n 6 localhost >Nul
Exit



:_Disable


Net user "%User%" /time:all

Cls & Mode CON  LINES=11 COLS=70 & Color 0E & Title Created By FreeBooter
Echo.
Echo.
Echo.
Echo.
Echo          Allowing the "%User%" Access to Windows at all Times
Echo.
Echo.
Echo.
Ping -n 6 localhost >Nul