PDA

Показать полную графическую версию : [решено] Нет доступа при копировании файлов в папку Windows\winsxs\Manife


Painkiller
26-10-2016, 21:38
Народ, проблема такова , нужно скопировать файлы в папку Windows\winsxs\Manifests , но у меня выскакивает ошибка при копировании , отказано в доступе .
Хотя привилегии включены
SetPrivilege('SeBackupPrivilege', True);
SetPrivilege('SeRestorePrivilege', True);
+ манефест и запускаю от имени администратора .
С этими привилегиями у меня нет проблем при удалении файлов и папок и не нужно получать на их права . Ну вот столкнулся с проблемами при копировании. Использую функцию

function CopyFiles(aSourceDir, aDestDir, aExt: string): Integer;

procedure BuildFilesList(aPath, aBasePath, aExt: string; aOutTS: TStrings);
var
SR: TSearchRec;

function ExpandRelativePath: string;
var
s: string;
begin
s := aPath + SR.Name;
Delete(s, 1, Length(aBasePath));
Result := s;
end;

begin
ZeroMemory(@SR, SizeOf(SR));
aPath := IncludeTrailingPathDelimiter(aPath);
if aExt = EmptyStr then
aExt := '*.*';
try
if (System.SysUtils.FindFirst(aPath + aExt, faAnyFile, SR) = 0) then
begin
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
if (SR.Attr and faDirectory) = faDirectory then
BuildFilesList(IncludeTrailingPathDelimiter(aPath + SR.Name),
aBasePath, aExt, aOutTS)
else
aOutTS.Add(ExpandRelativePath);
end;
until (System.SysUtils.FindNext(SR) <> 0);
end;
finally
System.SysUtils.FindClose(SR);
end;
end;

var
ts: TStringList;
i, r: Integer;
begin
Result := 0;
r := 0;
try
ts := TStringList.Create;
aSourceDir := IncludeTrailingPathDelimiter(aSourceDir);
aDestDir := IncludeTrailingPathDelimiter(aDestDir);
ForceDirectories(aSourceDir); // :D
ForceDirectories(aDestDir); // (:
BuildFilesList(aSourceDir, aSourceDir, aExt, ts);
if ts.Count = 0 then
Exit;
for i := 0 to ts.Count - 1 do
begin
if FileExists(aSourceDir + ts[i]) then
begin
ForceDirectories(ExtractFileDir(aDestDir + ts[i]));
if CopyFile(PChar(aSourceDir + ts[i]), PChar(aDestDir + ts[i]), False)
then
Inc(r);
end;
end;
finally
FreeAndNil(ts);
end;
Result := r;
end;

Как решить проблему ???

Painkiller
28-10-2016, 21:17
Вопрос решён !




© OSzone.net 2001-2012