I'm trying to find a way using, hopefully, a batch file to copy a modified user profile to the default user profile so that any user that logs in to the computer will adopt the profile setup. We're using a utility called pGina to call the default profile for a user logged in through a RADIUS server, as opposed to having the user log in to the domain directly. Currently, we're trying to use robocopy for this.
cd C:\Users\
rmdir Default /s /q
robocopy /COPY:DAT /R:5 /E C:\Users\user1 C:\Users\Default
pause
Does anyone have any idea how to successfully copy the profile? Thanks in advance.
This is what I found when searching for an answer to your problem
rem delete old Default User profile
RD /s /q "%systemdrive%\Profiles\Default User"
rem copy current user profile to default user profile
xcopy "%USERPROFILE%\*.*" "%systemdrive%\Profiles\Default User" /e /c /I /H /R /K /Y
rem delete non-need some files
del /f /q "%systemdrive%\Profiles\Default User\*.*"
rem set default attributes
attrib +h "%systemdrive%\Profiles\Default User"
rem registry trick
rem no directly copy locked ntuser.dat file
rem use reg tools to save current user registry to file
reg save HKCU "%systemdrive%\Profiles\Default User\ntuser.dat"
rem set default attributes to hive file
attrib +H +S "%systemdrive%\Profiles\Default User\ntuser.dat"
Related
I'm playing around with hacking on my virtual machine and in that tried to delete a folder which Windows created by default - "Videos" or "Documents", etc.
I would like to delete that folder from the cmd (I tried as an admin) but it doesn't seem to work. When deleting it from the GUI there were no issues.
I tried the following:
rmdir /s /q folderpath
And always get: Access is denied
start cmd in admin mode
takeown /F C:\{folder-name}\* /R /A
icacls C:\{folder-name}\*.* /T /grant administrators:F
rmdir /S /Q C:\{folder-name}\
From this StackOverflow answer:
RMDIR or RD if you are using the classic Command Prompt (cmd.exe):
rd /s /q "path"
If it tells you you have no access/permission to remove the directory, it's most likely an important Windows directory you shouldn't remove. You could try opening the CMD as Administrator, but be sure to check that it's safe to delete the folder.
I'm setting up a pair of logon and logoff scripts that will download and upload the users Outlook signatures automatically to and from their home directory (Z:\ drive).I'm using the scripts below, which work fine when run manually, but do not seem to be running at all (or at least not working) when set up as logon and logoff scripts with group policy. I have verified with gpresult that the scripts are indeed applied.
Logon Script (to download signatures):
#echo off
set LOGFILE=Z:\batch.log
call :LOG >> %LOGFILE%
exit /B
:LOG
if exist "Z:\Signatures\" (
xcopy /e /Y /D Z:\Signatures %appdata%\Microsoft\Signatures
)
Logoff Script (to upload signatures):
#echo off
set LOGFILE=Z:\batch.log
call :LOG >> %LOGFILE%
exit /B
:LOG
if not exist "Z:\Signatures\" (
mkdir Z:\Signatures
attrib +h Z:\Signatures /s /d
)
xcopy /e /Y /D %appdata%\Microsoft\Signatures Z:\Signatures
Does anyone have an idea why this wouldn't be working?
Fixed by using %homeshare% instead of the mapped Z:\ drive
I am working on a refresh project, and I am rebuilding and swapping out a lot of computers. When doing a reimage, I have a script I can run which will copy the Desktop, Favorites, and Documents from all user profiles to a network share.
What I don't have yet, is a script for hardware replacements (vs a reimage) that will transfer data directly from the old computer to the new one. As with my other script, I need it to transfer data from the Desktop, Favorites, and Documents folders for all user directories present on the old machine. If I wanted to go a step further, I might exclude specific user profiles such as Public, Default, my own profile, etc, but a more basic script would still work.
I have done some batch scripting on my own, but I'm not sure what the syntax needs to be to have it cycle through all the user profiles on a remote machine.
Here is what I have tried so far:
#echo off
Set /p remotepc=Enter remote hostname:
for /D %%D in ("\\%remotepc%\USERS\*") do (xcopy \\%remotepc%\Users\%%~fD\Desktop "C:\Users\%%~nxD\Desktop" /H /E /Y /K /I /R /C)
for /D %%D in ("\\%remotepc%\USERS\*") do (xcopy \\%remotepc%\Users\%%~fD\Documents "C:\Users\%%~nxD\Documents" /H /E /Y /K /I /R /C)
for /D %%D in ("\\%remotepc%\USERS\*") do (xcopy \\%remotepc%\Users\%%~fD\Favorites "C:\Users\%computername%\%%~nxD\Favorites" /H /E /Y /K /I /R /C)
pause
I'm trying to copy the ChromeData subfolder with permissions that may or may not be inside user profiles. so the folder structure is as follows.
-user1
-chromeData
-contacts
-desktop
-user2
-chromeData
-contacts
-desktop
the destination should be like this.
-user1
-ChromeData
-user2
-ChromeData
My code is as follows. It does copy the content in the chromeData folder to the destination, but it does not copy the permissions. Please note that I have used /mir /secfix and /copyall with robocopy. None of them worked. I saw a post saying robocopy does not copy inherited permissions. If this is true I need a workaround.
#echo off
setlocal EnableDelayedExpansion
set Source=F:\DFSroot\Redirected Content\
set Target=H:\Redirected ChromeData\
rem dir /s /ad /b "%Source%*.*" | find /i "\ChromeData" > C:\Temp\dir.txt
for /F "tokens=*" %%a in (C:\Temp\dir.txt) do (
set T1=%%a
call set T2=!T1:%Source%=%Target%!
robocopy "%%a" "!T2!" /copyall
pause
)
UPDATE
Found that permission is being copied for the chromedata folder but not its parent folder.
Use the following command to copy with the ACLs
robocopy "source address" "destination address" *.* /sec
Use the following command to fix an existing tree.
robocopy "source address" "destination address" *.* /secfix /sec
Found this information on this blog
How can we lock folder using Command Prompt, without setting the user permissions and without using the attrib command either.
First goto the folder directory and then type cacls folder_name /e /p everyone:n to lock and
cacls folder_name /e /p everyone:f to unlock.