Re: CopyHere

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.

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.

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

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
    ... You explained why the script would continue if it was unable to copy files, ... If the issue is simply the command being expected to create a directory ... documentation seems to say it should. ... 'Backup User Favorites ...
    (microsoft.public.scripting.vbscript)
  • Re: CopyHere
    ... The net result is that the user and script author do not have a clue as to ... Const FOF_SIMPLEPROGRESS = 256 ... 'Backup User Favorites ... 'Backup User PsiData (Need to check if folder exists on PC first) ...
    (microsoft.public.scripting.vbscript)
  • Re: CopyHere
    ... He's not trying to run through the copy command whether it copies or not ... The net result is that the user and script author do not have a clue as to ... 'Backup User Favorites ... 'Backup User PsiData (Need to check if folder exists on PC first) ...
    (microsoft.public.scripting.vbscript)