?
Solved

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

Posted on 2003-11-30
5
Medium Priority
?
3,275 Views
Last Modified: 2007-12-19
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
Comment
Question by:Crusher07
[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
5 Comments
 
LVL 5

Expert Comment

by:sanjaykashyap19
ID: 9847249
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
 

Author Comment

by:Crusher07
ID: 9847263
Yes, but I need a progress dialog box. I am copying over 500mb of data, so this is a necessity.
0
 
LVL 44

Accepted Solution

by:
bruintje earned 2000 total points
ID: 9848560
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
 
LVL 9

Expert Comment

by:TooKoolKris
ID: 9849897
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
 

Author Comment

by:Crusher07
ID: 9851207
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

800 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