• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3333
  • Last Modified:

CopyHere VBScript method working on Windows 2000, but not on XP...

Hello,

I am trying to copy the contents of one folder to another using the following VBScript code:

set SA = CreateObject("Shell.Application")
set FolderObj = SA.NameSpace("C:\temp")
FolderObj.CopyHere "C:\HLCache\*.*" , 16+512

The thing is, in Windows 2000, this code works fine, the progress dialog appears and copies the files in the right place. I am running WSH 5.6 on that system. But in Windows XP, I receive this error message:

C:\DOCUME~1\Robert\LOCALS~1\Temp\~shlcpy.vbs(3, 1) Microsoft VBScript runtime er
ror: Object required: 'FolderObj'

I am also running WSH 5.6 on Windows XP. The same message appears for other Windows XP machines I have too. I need to use the CopyHere method as this is the only way I can have a progress indicator. But why would it work on Windows 2000 and not in XP?

Please can someone help me!
0
Crusher07
Asked:
Crusher07
1 Solution
 
sanjaykashyap19Commented:
try with FileSystemObject

Set FSO = CreateObject("Scripting.FileSystemObject")
set Folderobj = FSO.GetFolder(LogFileDir)


for delete file sample code look http://www.iisfaq.com/default.aspx?View=A65&P=141


0
 
Crusher07Author Commented:
Yes, but I need a progress dialog box. I am copying over 500mb of data, so this is a necessity.
0
 
bruintjeCommented:
Title : Windows XP Shell.Application CopyHere bug
Source : http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=9uq81c%24gt3%241%40lust.ihug.co.nz

Description :
-----------

The object is a Folder it copies a folder
To copy files (inc *.*) you need to specify a object items

' script to demo shell.application (for IE4/5 in win98)

Option Explicit
Dim oSHApp, oSHFolder ' as object
Dim sSrc, sDest ' as string
Set oSHApp = CreateObject("Shell.Application")

sSrc = "C:\Scripts"
sDest = "C:\Temp\"

'If sSrc is a folder whose contents you want to copy
Set oSHFolder = oSHApp.Namespace(sSrc)
oSHApp.Namespace(sDest).CopyHere oSHFolder.Items

'If sSrc is one File or whole Folderyou want to place inside sDest
'oSHApp.Namespace(sDest).CopyHere sSrc, &H100

Set oSHFolder = Nothing
Set oSHApp = Nothing
WScript.Quit

-----------

from the rest of that google thread and several others it looks like a bug, copyfolder seems to work or without asteriks the method should work too

hope this helps a bit
0
 
TooKoolKrisCommented:
You could add your own progress indicator with the Copy or CopyFile methods however it wont look as neat as the one windows pops up for you. It will simply send a bunch of "." to the console to let you know that it is still in progress, however there wont be any indication of how far it has gone or how much is has left to do.  If this ounds like something you want to do let me know and I'll post the code.
0
 
Crusher07Author Commented:
Wow, this must one one of those oh-so-rare occasions where it is actually a bug!

Good work - The new code works great. I knew I couldn't have been the only one with this problem... lets just hope MS actually do something about it, i.e. fix it in SP2.

Thanks everyone for a speedy response.

Robert

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now