Access denied when trying to copy files

Discussion in 'Windows 8' started by NICK@NUMBER11, Jun 3, 2014.

  1. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    Hi, i am trying to copy/replace some files using a bat and every time i get access denied..... :mad:




    does anyone have any ideas..... :tea:
     
  2. Aemsa

    Aemsa MDL Member

    Feb 17, 2014
    116
    27
    10
    Try running the .bat as administrator (right click) and see if it works correctly.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,219
    84,887
    340
    #3 abbodi1406, Jun 3, 2014
    Last edited by a moderator: Apr 20, 2017
    try
    Code:
    xcopy /chryi "dep.dll" "C:\Program Files (x86)\depdatabase"
     
  4. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    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
     
  5. HALIKUS

    HALIKUS MDL Addicted

    Jul 29, 2009
    526
    371
    30
    #5 HALIKUS, Jun 4, 2014
    Last edited: Jun 4, 2014
    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
     
  6. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #6 NICK@NUMBER11, Jun 4, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    nope still the same access denied

     
  7. murphy78

    murphy78 MDL DISM Enthusiast

    Nov 18, 2012
    7,389
    11,614
    240
    #7 murphy78, Jun 4, 2014
    Last edited by a moderator: Apr 20, 2017
    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"
    :--------------------------------------
     
  8. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    #8 NICK@NUMBER11, Jun 4, 2014
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Works 100% Thanks....... :worthy::biggrin::worthy:


     
  9. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,219
    84,887
    340
    You were trying to copy it without admin privileges?
    come on, even ian82 knows that it's required for such process :glare: :D
     
  10. NICK@NUMBER11

    NICK@NUMBER11 MDL Expert

    Mar 23, 2010
    1,503
    720
    60
    Yep i was :eek:

    :hummer: