Hi, i am trying to copy/replace some files using a bat and every time i get access denied..... does anyone have any ideas.....
gotta use /h in to copy to/from hidden or system files like abbodi says... the arguments are a little weird in that you don't need a / for each one. so you can combine them like /hy would copy hidden/system files without a yes prompt
what abbodi said. ie: if exist %Scripts%\InstallTips.ini cmd /c echo F | XCOPY /c /q %Scripts%\InstallTips.ini %Scripts%\InstallTips_x86.ini cmd /c echo F | xcopy %Scripts%\Overlay\81x86\*.* %systemdrive% /cherkyi :InstallTips if %PROCESSOR_ARCHITECTURE% == x86 ( echo InstallTips.exe & If Exist %Scripts%\InstallTips.exe start /wait %Scripts%\InstallTips.exe ) else ( if exist %Scripts%\InstallTips.ini cmd /c echo F | XCOPY /c /q %Scripts%\InstallTips.ini %Scripts%\InstallTips_x86.ini if exist %Scripts%\InstallTips.ini DEL /f /q %Scripts%\InstallTips.ini if exist %Scripts%\InstallTips_x64.ini cmd /c echo F | XCOPY /c /q %Scripts%\InstallTips_x64.ini %Scripts%\InstallTips.ini echo InstallTips.exe x64 & If Exist %Scripts%\InstallTips.exe start /wait %Scripts%\InstallTips.exe ) echo. & goto :eof
It's probably the data execution prevention stuff since it's a system folder. I haven't tried this, but you could try adding this to beginning of your script to bypass the UAC check: Code: :Begin UAC check and Auto-Elevate Permissions :------------------------------------- REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo: echo Requesting Administrative Privileges... echo Press YES in UAC Prompt to Continue echo: goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) pushd "%CD%" CD /D "%~dp0" :--------------------------------------
You were trying to copy it without admin privileges? come on, even ian82 knows that it's required for such process