Board logo

标题: cmd下如何替换只读文件? [打印本页]

作者: qdcr     时间: 2006-7-6 16:30    标题: cmd下如何替换只读文件?

@echo off
copy setup.exe c:\setup.exe /y
pause > nul

c:\setup.exe已经存在,并且只读,
运行该脚本,提示
Access is denied.
        0 file(s) copied.
请问如何强制拷贝文件,能覆盖目标只读文件.
作者: doscc     时间: 2006-7-6 20:44
@echo off
dir c:\ /a:r |find /I "setup.exe" >NUL && goto cp
copy setup.exe c:\setup.exe
exit
:cp
attrib -r setup.exe
copy setup.exe c:\setup.exe
作者: flysp     时间: 2006-7-9 09:50
if exist c:\setup.exe del /f /q c:\setup.exe  && copy /b /y setup.exe  c: