Link to home
Start Free TrialLog in
Avatar of bguenther
bguenther

asked on

How to Overwrite a file in c:\windows..... backup permissions restore permissions

Hi Everyone,

i am trying to create a function where i can specify a source file and a target file.
I want to store the permissions that the target file has and backup the target file.
Copy the source file to the target files location and name.
Set permissions for the new file to match the old file (eg System, Trusted Installer etc....)

The file copying is pretty simple but i don't how to get permission for the file or set them on the new file.

Can anyone help with this?
Also being allowed to copy to a location like: C:\windows\winsxs\wow64_microsoft-windows-a..cing-infrastructure_31bf3856ad364e35_6.1.7600.16385_none_0bfcc31f07a61f6d\

'Create backup
System.IO.File.Move(strTargetFile, strTargetFile & ".bak")

'Copy file
System.IO.File.Copy(strSourceFile, strTargetFile)
SOLUTION
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bguenther
bguenther

ASKER

Thanks for your help. i will see what i can make of it