Solved

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

Posted on 2003-11-30
5
3,267 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 500 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

729 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