Adicione o usuário e defina o Diretório base no local:
NET USER UserName DerParol /add /comment:"Account for User" /expires:never /homedir:C\Acc\UserName
Adicione o usuário ao grupo Administradores local.
NET LOCALGROUP Administrators /add UserName
PSexec
parte do Sysinternals Suite
Criar um perfil de usuário
proinit.cmd:
@ECHO OFF
SETLOCAL
SET Profile=C:\Acc
SET user=Troll
SET password=DerParol
SET PSEXEC="C:\Program Files\SysinternalsSuite\PSEXEC"
SET wmic=%windir%\system32\wbem\wmic
FOR /F "tokens=2* delims= " %%I IN ('REG QUERY ^"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList^" /v ProfilesDirectory^|find /i ^"ProfilesDirectory^"') DO (
SET ProfilesDirectory=%%J)
@echo ProfilesDirectory: %ProfilesDirectory%
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v ProfilesDirectory /t REG_SZ /d "%Profile%" /f
REG ADD "HKCU\Software\Sysinternals\PsExec" /v EulaAccepted /t REG_DWORD /d 1 /f
NET USER /add %user% %password% /comment:"Account for User" /expires:never /homedir:%Profile%\%user% /profilepath:%Profile%\%user%
NET LOCALGROUP Administrators /add %user%
%PSEXEC% -h -u %user% -p %password% "%wmic% QUIT"
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v ProfilesDirectory /t REG_SZ /d "%ProfilesDirectory%" /f
Domínio,use:dsadduser
@ECHOOFF@SETuser=UserName@SETpassword=DerParole@SETpwdSet=-canchpwdyes-pwdneverexpiresyes::-mustchpwdyes@SETaccSet=-disabledno-acctexpiresnever-upn%user%@%USERDNSDOMAIN%-samid%user%@SETdirSet=-profile\SERV\Acc\%user%-hmdrvR:-hmdir\SERV\Acc\%user%-loscrenver.cmd@SETBrand=-office"Grand-1" -company TT -dept HT -title MegaUser
@SET locSet=-tel 914-55-04-42 -email %user%II@%USERDNSDOMAIN% -webpg %user%.%USERDNSDOMAIN%
@SET callIn=-hometel 9-slip-010-292 -pager 1022 -mobile "8(777) 101-44-22" -fax "977-101-44-22" -iptel 6002
@SET nameSt=-fn User -ln Name -mi "U.N." -display "UserName II"
@SET Description=-desc "Account for User"
::@SET cmSet=@ECHO dsadd user
@SET cmSet=dsadd user
@For /F %%a In ('dsquery * -filter "(objectCategory=domain)"') Do @SET dc=%%a
@SET dn="cn=%user%,cn=users,%dc:~1%
::@SET grpSet=-memberof "cn=ResourceGroup,cn=users,%dc:~1%
%cmSet% -pwd %password% %dn% %pwdSet% %accSet% %dirSet% %Brand% %locSet% %callIn% %nameSt% %Description% -uc
dsquery * -filter "(samAccountName=%user%)" -attr * | more
script em lote de teste do usuário dsadd: