JSI Tip 1744. How do I copy files to every user's home directory?

Jerold Schulman

October 25, 1999

1 Min Read
ITPro Today logo


HomeCopy.bat uses only standard commands. It assumes that each user's home directory has a common parent folder, as in:

      c:users
      c:usersuser1
      c:usersuser2

The syntax is:

HomeCopy

file1[,file2,file3,....fileN]

HomeCopy.bat contains:

@echo offif NOT {%1}

<a name="_goto_begin_if_NOT_2_" id="_goto_begin_if_NOT_2_">{} goto beginif NOT {%2}</a>

{} goto begin:syntax@echo Syntax: HomeCopy Parent_Folder File1[,file2,file3,.....filen]goto end:finishendlocalgoto end:beginsetlocalif NOT EXIST %1 goto syntaxset parent=%1set parent=%parent:"=%:loopShiftIf {%1}=={} goto finishif NOT EXIST %1 goto syntaxset filefull=%1set file=%~nx1for /f "Tokens=*" %%i in ('dir "%parent%" /B /AD') do call :parse "%%i"goto loop:parseset child=%1set child=%child:"=%if exist "%parent%%child%%file%" del /q "%parent%%child%%file%"copy %filefull% "%parent%%child%":end


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like