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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyway to copy hidden files too...

Status
Not open for further replies.

Ross1811

MIS
Oct 1, 2004
122
US
Hello Everyone,

This script works well for me but the only problem that it has is that it does not copy hidden files also. Is there anyway I can modify this script to copy hidden files too?

Thanks,
Ross
Code:
 Option Explicit
 Dim oSHApp, oSHFolder, ErrNum
 Set oSHApp = CreateObject("Shell.Application")
 Set oSHFolder = oSHApp.Namespace("C:\test")
 
 oSHApp.Namespace("C:\test2").CopyHere oSHFolder.Items,16+512
 
you might want to try it with the FileSystemObject

Code:
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Test\*.*" , "C:\Test2\" , OverwriteExisting

set objFSO = Nothing

Reference to the FileSystemObject:

I hope this helps....
 
is there a way that I could put that on the folder?, I dont want to try looping through all the folder and subfolders to copy every single file.
Is there another way? using the Shell.application?????

Ross
 
Just replace CopyFile with CopyFolder like so:
Code:
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Test" , "C:\Test2" , OverwriteExisting

set objFSO = Nothing

Pls read:

I have to investigate on "shell.application"

I hope this helps...
 
you can use the xcopy command.
xcopy c:\folder\*.* /h
this copies hidden and system files.
other options:
 
sorry, i forgot to mention. that was a dos command. you have to imbed it in vbs using .run
 
Yes I know those things would work, I wanted it to copy all my files even hidden with the shell.application, in my original code, this give me a verbose output,



Thanks,
Ross
 
got it!
this example is straight from:

Code:
dim objShell
dim objFolder
        
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace("C:\target")
 
if not objFolder is nothing then
   objFolder.CopyHere("C:\source\*.*"),16+512
end if
 
set objShell = nothing
set objFolder = nothing

this copies hidden and system-files.

I hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top