Question : Replace file with a batch file

I have a file in C:\ProgramData\avg9\Cfg\admin.cfg that needs to be replaced. I have to do this on hundreds of machines. I am going to create a batch file which should make thing easier. I want the batch file to delete C:\ProgramData\avg9\Cfg\admin.cfg and replace it with another exact same file but newer C:\Users\jess.RELIABLE\Desktop\Windows 7\admin.cfg. Please help..

Answer : Replace file with a batch file

If you want it to be copied at any restart where the new file exists, then it should be as simple as:

@echo off
set FromFile=%userprofile%\Desktop\Windows 7\admin.cfg
set ToFile=C:\ProgramData\avg9\Cfg\admin.cfg
if exist "%FromFile%" copy /Y "%FromFile%" "%ToFile%" >NUL

If you only want it to copy one time, then you could create a little flag file that indicates the copy was done, like this:

@echo off
set FromFile=%userprofile%\Desktop\Windows 7\admin.cfg
set ToFile=C:\ProgramData\avg9\Cfg\admin.cfg
set ToFlag=C:\ProgramData\avg9\Cfg\admin.done
if exist "%FromFile%" (
  if not exist "%ToFlag%" (
    copy /Y "%FromFile%" "%ToFile%" >NUL
    echo Done>"%ToFlag%"
  )
)

~bp
Random Solutions  
 
programming4us programming4us