Advertisement
shchuko

script21.cmd

Feb 18th, 2020
1,640
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2.  
  3. cls
  4. :enter_name
  5. set /p NAME="Enter user name (4 characters): "
  6. goto checklen
  7.  
  8. :reenter_name
  9. echo Name should be 4 chars length! Enter another one
  10. goto enter_name
  11.  
  12. :checklen
  13. call :strLen NAME LEN
  14. if not %LEN% == 4 goto :reenter_name
  15.  
  16. set USERNAME=UPart2%NAME%
  17. set GROUPNAME=GPart2%NAME%
  18.  
  19. net user %USERNAME% /add
  20. net localgroup %GROUPNAME% /add
  21. net localgroup %GROUPNAME% %USERNAME% /add
  22. net user %USERNAME% /active:yes
  23.  
  24. net user
  25. net localgroup
  26. net localgroup %GROUPNAME%
  27. pause
  28. exit /b
  29.  
  30. :strLen  strVar  [rtnVar]
  31. setlocal disableDelayedExpansion
  32. set len=0
  33. if defined %~1 for /f "delims=:" %%N in (
  34.   '"(cmd /v:on /c echo(!%~1!&echo()|findstr /o ^^"'
  35. ) do set /a "len=%%N-3"
  36. endlocal & if "%~2" neq "" (set %~2=%len%) else echo %len%
  37. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement