Re: CopyHere




"Paul Randall" <Paulr901@xxxxxxxxxxxx> wrote in message
news:%234HwKHQIKHA.5956@xxxxxxxxxxxxxxxxxxxxxxx
Comments inline

"Eric" <someone@xxxxxxxxxxxxxxxxx> wrote in message
news:%23mxY6NPIKHA.1684@xxxxxxxxxxxxxxxxxxxxxxx
On Error Resume Next does not apply here.

If the statement is there and not commented out, it applies.

You explained why the script would continue if it was unable to copy files,
which wasn't the question.
The question was asking for help on a CopyHere command which was not
creating a directory that doesn't exist.
Telling him why he doesn't see an error doesn't help fix the problem of not
copying the files.
Your answer only seems to suggest removing the on error statement from a
script which is executed by end users in order to show them messages they
likely won't understand.

He's not trying to run through the copy command whether it copies or not

The comments in the code may tell what he is trying to do. The code can
only tell what he IS doing, not what he intends to do. The code says he
is running through the commands and taking the standard 'On Error Resume
Next' actions if and when any error occurs.

The comments in the code just say the code is trying to backup (copy) files.
Why do you care if the comments in the code tell what he intends to do?
Did you read the message above the code that tells what he expects it to
do??

then check for a message on why it failed.
If the issue is simply the command being expected to create a directory
that doesn't exist and it's not creating, just add a check and create
before the copy.

I think it is poor programming practice to design and implement a
workaround whenever it appears that some command does not work as the
documentation seems to say it should. This just leads to longer code and
less trust in the documentation. Removing the error obfuscating
statement, and reporting here any errors he cannot resolve by himself
might lead to better code, a better understanding of the command causing
the problem, and better trust in the documentation, and maybe an
understanding of what is different about the 25% of the machines with the
problem.

-Paul Randall

Where do you see documentation that says CopyHere is supposed to create
directories?
The only official documentation I'm aware of on the command is at the MS
link I mentioned in the first post in this thread. I don't see that there.
It is a poor programming practice to execute a command which does something
which is not documented and assume it's supposed to always do that.
Proper practice would be to use the directory methods for checking existance
of and creating the directories.
Removing On Error Resume Next is always a bad idea for scripts to be used by
end users. If you want to see why something failed, put a fail check after
that statement.
If Err.Number <> 0 Then
errlog.WriteLine(Err.Description)
End If

http://www.devguru.com/technologies/VBScript/14059.asp

"Paul Randall" <Paulr901@xxxxxxxxxxxx> wrote in message
news:euyr0rOIKHA.2516@xxxxxxxxxxxxxxxxxxxxxxx
Perhaps it is time to learn about the "On Error Resume Next" statement.
When used in a main script, without other error handling statements, it
basically means:
1) Please don't inform the user when or where or why errors occur
2) Please change the order in which statements are executed, in various
ways, depending on where an error occurs
3) Please keep on going no matter how many errors occur.

The net result is that the user and script author do not have a clue as
to what statements may or may not have been executed when the script is
done.

-Paul Randall

"James" <dontemailme@xxxxxxxxxxxxxxx> wrote in message
news:O4tY2IOIKHA.4004@xxxxxxxxxxxxxxxxxxxxxxx
I am having a similar problem. My code is below. The copyhere will not
automatically create the directory if it doesn't already exist. Weird
thing is that it will automatically create the directory if it doesn't
exist on 75% of the machines I have but not the other 25%. Any help you
could provide would be greatly appreciated. This is pure vbs, no hta or
html involved.

On Error Resume Next
Set objNetwork = CreateObject("Wscript.Network")
Set objSHApp= CreateObject("Shell.Application")
Const FOF_CONFIRMALL = 16
Const FOF_SIMPLEPROGRESS = 256
Const FOF_CREATEDIR = 512
Set WshShell = WScript.CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set WshSysEnv = WshShell.Environment("PROCESS")

'Set destination
strDest = "G:\ProfileBackup\"

'Check if the ProfileBackup Folder exist, if not create it
If Not filesys.FolderExists(strDest) Then
filesys.CreateFolder(strDest)
End If

'Set source path strings
strHomePath = WshSysEnv("HOMEPATH")
strSrcDesktop = "c:" & strHomePath & "\desktop"
strSrcFavs = "c:" & strHomePath & "\Favorites"
strSrcMyDocs = "c:" & strHomePath & "\My Documents"
strSrcPsiData = "c:" & strHomePath & "\PsiData"
strSrcEmailSig = "c:" & strHomePath & "\Application
Data\Microsoft\Signatures"

' Using shell.application to copy since faster and displays
status/progress

'Backup User Desktop
objSHApp.Namespace(strDest).CopyHere strSrcDesktop,FOF_CONFIRMALL

'Backup User Favorites
objSHApp.Namespace(strDest).CopyHere strSrcFavs,FOF_CONFIRMALL

'Backup User My Documents
objSHApp.Namespace(strDest).CopyHere strSrcMyDocs,FOF_CONFIRMALL

'Backup User PsiData (Need to check if folder exists on PC first)
If filesys.FolderExists (strSrcPsiData) Then
objSHApp.Namespace(strDest).CopyHere strSrcPsiData,FOF_CONFIRMALL
End If

'Backup User Email Signatures (Need to check if folder exists on PC
first)
If filesys.FolderExists (strSrcEmailSig) Then
objSHApp.Namespace(strDest).CopyHere strSrcEmailSig,FOF_CONFIRMALL
End If

James



"Pegasus [MVP]" <news@xxxxxxxxxxxxx> wrote in message
news:%23yWJ$NEIKHA.5256@xxxxxxxxxxxxxxxxxxxxxxx

"Eric" <someone@xxxxxxxxxxxxxxxxx> wrote in message
news:eHK7rHEIKHA.1340@xxxxxxxxxxxxxxxxxxxxxxx
MS says CopyHere has options.
http://msdn.microsoft.com/en-us/library/bb787866(VS.85).aspx
I execute it with options and it ignores them. Am I missing
something or is MS missing something?

Let's have a look at your script!











.



Relevant Pages

  • Re: CopyHere
    ... You explained why the script would continue if it was unable to copy ... The question was asking for help on a CopyHere command which was not ... documentation seems to say it should. ... 'Backup User Favorites ...
    (microsoft.public.scripting.vbscript)
  • Re: CopyHere
    ... If the issue is simply the command being expected to create a directory ... whenever it appears that some command does not work as the documentation ... When used in a main script, without other error handling statements, it ... 'Backup User Favorites ...
    (microsoft.public.scripting.vbscript)
  • Re: Problems trying to configure Linux laptop to print to Windows XP shared printer
    ... map to guest = Never ... check password script = ... enumports command = ... ldap delete dn = No ...
    (comp.os.linux.setup)
  • Problems trying to configure Linux laptop to print to Windows XP shared printer
    ... map to guest = Never ... check password script = ... enumports command = ... ldap delete dn = No ...
    (comp.os.linux.setup)
  • Re: MATLAB Code for a stop process button which ex
    ... especially in the while loop(for each script command starting in the ... % varargin command line arguments to stop_button ... % line_num is the order of execution. ... msgno = msgno+1; ...
    (comp.soft-sys.matlab)

Loading