Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I copy files and folders keeping source attributes

Status
Not open for further replies.

stevemarks59

Technical User
Apr 8, 2010
22
US
I have XP-Pro SP3 with Power Shell installed.


I need a script I can drag and drop files and folders onto that will copy them maintaining the attributes of the source.

Specifically most of my folders have distributable custom icons. Each folder contains both a "desktop.ini" file and an associated "FolderMarker.ico" the "desktop.ini" file points to. Both of these files have "system" and "hidden" attributes. In order for the folders to display the custom icons when copied to another computer these files have to keep the "system" attribute and I want the "hidden" attribute maintained as well.

I haven't been able to do this using VBscript. I have to use XXcopy which doesn't allow me to copy by just dropping the folders on the script. (VBscript does allow me to copy by dropping items on the script but the copied folder icons are not distributable because the "system" and "hidden" attributes of the "desktop.ini" and "FolderMarker.ico" are lost when copied by that method.

I would really appreciate a script to accomplish this. Below is the VBscript to which I refer. Thanks.


------------------------------------------------------
On Error Resume Next
Const OverwriteExisting = True
Set objArgs = WScript.Arguments
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objArgs.Count < 1 Then
WScript.Quit
End If
For I = 0 to objArgs.Count - 1

Arg = objArgs(I)

objFSO.CopyFile Arg, "C:\Program Files\", OverwriteExisting
objFSO.CopyFile Arg, "D:\0 aAPPS\00 a Install First\Program Files\", OverwriteExisting
objFSO.CopyFolder Arg, "C:\Program Files\", OverwriteExisting
objFSO.CopyFolder Arg, "D:\0 aAPPS\00 a Install First\Program Files\", OverwriteExisting

Next
WScript.Quit
------------------------------------------------------
 
I don't know if the script provided at the link above is powershell or vbs and don't really care because it does what I desired. So if it is a vbs script I apologize to any who may be upset at a vbs posting in a powershell forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top