?
Solved

Copy files from a CD to HD and reset read-only attribute

Posted on 2008-10-31
3
Medium Priority
?
336 Views
Last Modified: 2012-08-14
Hi.  I need help with a script that simply copies folders (and files) from a CD to a folder structure on the hard drive.  I have the code to do this, but I can't run it multiple times as the original copy flags everything readonly.  How do I copy from the CD and NOT set the read only attribute on the HD?  Either that or how do I remove the read only flag onl the entire folder structure once copied over?

Thanks.
My code so far:
dim objFSO
dim objFolder
dim objShell


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

strDestFolder = "C:\Sales Presentation"

'  Delete Folder first
'If objFSO.FolderExists(strDestFolder) then
'    objFSO.DeleteFolder(strDestFolder)
'End If

'  Create new folder
If Not objFSO.FolderExists(strDestFolder) then
    objFSO.CreateFolder(strDestFolder)
End If
'msgbox (strDestFolder & " Folder Created.")

'  Get Drive Letter where presentation is stored.
strPath = objShell.CurrentDirectory
strInstallDrive = objFSO.GetDriveName(strPath)
Wscript.Echo strInstallDrive
strInstallDrive="D:"

'  copy files from CD to C:\ drive
objFSO.CopyFolder strInstallDrive & "\Sales Presentation\*.*" , strDestFolder , true
0
Comment
Question by:JasonJewett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
SRigney earned 2000 total points
ID: 22852555
Const READ_ONLY = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Scripts\Computers.txt")

If objFile.Attributes AND READ_ONLY Then
    objFile.Attributes = objFile.Attributes XOR READ_ONLY
End If


Info pulled from http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan05/hey0118.mspx
0
 

Author Comment

by:JasonJewett
ID: 22852758
Thanks, but how do I do this for all files in the three subfolders as well?  I really like a way to copy them over without keeping the RO flag set instead of copying them over and then unflaging RO.

0
 
LVL 15

Assisted Solution

by:SRigney
SRigney earned 2000 total points
ID: 22853023
I did something very similar several years ago.  I had a project where a company was sending files on a CD and we needed to process them.  I had to use the FileSystemObject to set each file to not be read only.

What I did was copy the entire CD over, then loop through all files in all subfolders from the destination and change this setting.  

Later I changed my other process to check if the file was read-only before it started to use it, then it would change it to not read-only, which allowed the handling of files step to take care of the read-only flag itself.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question