При запуске необходимо указать путь к папке профиля (обычно c:\users\username).
@echo off echo. :enteruname set /p uname=Please enter userprofile folder name: if not defined uname goto enteruname echo. :rename echo 1) Renaming of user profile FOR /F %%a IN ('psgetsid \\%cname% %uname% /accepteula') DO set sid=%%a echo %uname%'s SID is %sid% for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%sid%" /v ProfileImagePath') do set profilepath=%%a echo User profile is located in %profilepath% echo. if exist %profilepath%_old ren %profilepath%_old %uname%_old_%random% ren %profilepath% %uname%_old if %ERRORLEVEL% EQU 0 (echo User profile renamed from %uname% to %uname%_old & goto ren_ok) else (echo Failed to rename profile folder, please restart computer now!) echo Press ANY KEY to restart a computer and then login under administrator account! REG ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v !RecreateProfile /t REG_SZ /d c:\temp\recreate_user_profile.bat /f pause shutdown -r -t 0 -f goto rename echo. :ren_ok reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" > c:\temp\profiles.txt findstr "%sid%" c:\temp\profiles.txt > c:\temp\usersid.txt echo 2) Registry keys for user %uname% found: type c:\temp\usersid.txt pause for /f "tokens=*" %%a in (c:\temp\usersid.txt) do reg delete "%%a" /f if %ERRORLEVEL% EQU 0 (echo Regitry key for user %uname% deleted.) else (echo Failed to delete registry record!) echo. echo 3) It's time to copy user's data from old profile to a new one echo %userfolder%_old > \\%cname%\c$\temp\profilename.txt REG ADD "HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v !CopyProfile /t REG_SZ /d c:\temp\copy_profile.bat /f echo. Now you can ask user to login, after he is logged run C:\Temp\copy_profile.bat to move contents of the old profile to a new one. echo. timeout 7