Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - CopyHere

Reply
 
Old 08-18-2009   #1 (permalink)
Eric


 
 

CopyHere

MS says CopyHere has options.
http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
I execute it with options and it ignores them. Am I missing something or is
MS missing something?



My System SpecsSystem Spec
Old 08-18-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: CopyHere


"Eric" <someone@xxxxxx> wrote in message
news:eHK7rHEIKHA.1340@xxxxxx
Quote:

> MS says CopyHere has options.
> http://msdn.microsoft.com/en-us/libr...66(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!


My System SpecsSystem Spec
Old 08-18-2009   #3 (permalink)
Eric


 
 

Re: CopyHere


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

>
> "Eric" <someone@xxxxxx> wrote in message
> news:eHK7rHEIKHA.1340@xxxxxx
Quote:

>> MS says CopyHere has options.
>> http://msdn.microsoft.com/en-us/libr...66(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!
Just a basic copy. I tried a couple options (confirmall, simpleprogress)
and it seems to ignore.


Option Explicit
Dim oSHApp, sFolder ' as object
Dim sSrc, sDest ' as string

Const FOF_NODIALOG = 4
' Do not display a progress dialog box.
Const FOF_RENAMEIFEXISTS = 8
' Give the file being operated on a new name in a move, copy, or rename
operation if a file with the target name already exists.
Const FOF_CONFIRMALL = 16
' Respond with "Yes to All" for any dialog box that is displayed.
Const FOF_PRESERVEUNDO = 64
' Preserve undo information, if possible.
Const FOF_WILDCARDSONLY = 128
' Perform the operation on files only if a wildcard file name (*.*) is
specified.
Const FOF_SIMPLEPROGRESS = 256 '(&H100)
' Display a progress dialog box but do not show the file names.
Const FOF_CREATEDIR = 512
' Do not confirm the creation of a new directory if the operation requires
one to be created.
Const FOF_NOERRORDISPLAY = 1024
' Do not display a user interface if an error occurs.
Const FOF_NOSECURITYCOPY = 2048
' Version 4.71. Do not copy the security attributes of the file.
Const FOF_NOSUBDIRECTORIES = 4096
' Only operate in the local directory. Don't operate recursively into
subdirectories.
Const FOF_NOCONNECTEDFILES = 8192
' Version 5.0. Do not copy connected files as a group. Only copy the
specified files.

Set oSHApp = CreateObject("Shell.Application")

sSrc = "c:\testsource\*.*"
sDest = "c:\testdest\"
set sFolder = oSHApp.NameSpace(sDest)

if not sFolder is nothing then
sFolder.CopyHere sSrc,FOF_CONFIRMALL
end if

Set oSHApp = nothing ' clean up
WScript.Quit


My System SpecsSystem Spec
Old 08-18-2009   #4 (permalink)
Todd Vargo


 
 

Re: CopyHere

Eric wrote:
Quote:

> MS says CopyHere has options.
> http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
> I execute it with options and it ignores them. Am I missing something or
is
Quote:

> MS missing something?
It works for me. Show us how you implemented it.

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 08-18-2009   #5 (permalink)
Todd Vargo


 
 

Re: CopyHere

Eric wrote:
Quote:

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

> >
> > "Eric" <someone@xxxxxx> wrote in message
> > news:eHK7rHEIKHA.1340@xxxxxx
Quote:

> >> MS says CopyHere has options.
> >> http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
> >> I execute it with options and it ignores them. Am I missing something
or
Quote:
Quote:
Quote:

> >> is MS missing something?
> >
> > Let's have a look at your script!
> Just a basic copy. I tried a couple options (confirmall, simpleprogress)
> and it seems to ignore.
>
>
> Option Explicit
> Dim oSHApp, sFolder ' as object
> Dim sSrc, sDest ' as string
>
> Const FOF_NODIALOG = 4
> ' Do not display a progress dialog box.
> Const FOF_RENAMEIFEXISTS = 8
> ' Give the file being operated on a new name in a move, copy, or rename
> operation if a file with the target name already exists.
> Const FOF_CONFIRMALL = 16
> ' Respond with "Yes to All" for any dialog box that is displayed.
> Const FOF_PRESERVEUNDO = 64
> ' Preserve undo information, if possible.
> Const FOF_WILDCARDSONLY = 128
> ' Perform the operation on files only if a wildcard file name (*.*) is
> specified.
> Const FOF_SIMPLEPROGRESS = 256 '(&H100)
> ' Display a progress dialog box but do not show the file names.
> Const FOF_CREATEDIR = 512
> ' Do not confirm the creation of a new directory if the operation requires
> one to be created.
> Const FOF_NOERRORDISPLAY = 1024
> ' Do not display a user interface if an error occurs.
> Const FOF_NOSECURITYCOPY = 2048
> ' Version 4.71. Do not copy the security attributes of the file.
> Const FOF_NOSUBDIRECTORIES = 4096
> ' Only operate in the local directory. Don't operate recursively into
> subdirectories.
> Const FOF_NOCONNECTEDFILES = 8192
> ' Version 5.0. Do not copy connected files as a group. Only copy the
> specified files.
>
> Set oSHApp = CreateObject("Shell.Application")
>
> sSrc = "c:\testsource\*.*"
> sDest = "c:\testdest\"
> set sFolder = oSHApp.NameSpace(sDest)
>
> if not sFolder is nothing then
> sFolder.CopyHere sSrc,FOF_CONFIRMALL
> end if
>
> Set oSHApp = nothing ' clean up
> WScript.Quit
What OS and what version of vbscript are you using. Did the destination
folder exist before attempting to copy files to it? AFAIK, CopyHere does not
create the destination folder. By "seems to ignore", what results were you
expecting from the code above? Was there a large amount of data in the
source folder to be copied?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 08-19-2009   #6 (permalink)
Eric


 
 

Re: CopyHere


"Todd Vargo" <tlvargo@xxxxxx> wrote in message
news:ecgqXtEIKHA.3736@xxxxxx
Quote:

> Eric wrote:
Quote:

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

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

>> >> is MS missing something?
>> >
>> > Let's have a look at your script!
>> Just a basic copy. I tried a couple options (confirmall, simpleprogress)
>> and it seems to ignore.
>>
>>
>> Option Explicit
>> Dim oSHApp, sFolder ' as object
>> Dim sSrc, sDest ' as string
>>
>> Const FOF_NODIALOG = 4
>> ' Do not display a progress dialog box.
>> Const FOF_RENAMEIFEXISTS = 8
>> ' Give the file being operated on a new name in a move, copy, or rename
>> operation if a file with the target name already exists.
>> Const FOF_CONFIRMALL = 16
>> ' Respond with "Yes to All" for any dialog box that is displayed.
>> Const FOF_PRESERVEUNDO = 64
>> ' Preserve undo information, if possible.
>> Const FOF_WILDCARDSONLY = 128
>> ' Perform the operation on files only if a wildcard file name (*.*) is
>> specified.
>> Const FOF_SIMPLEPROGRESS = 256 '(&H100)
>> ' Display a progress dialog box but do not show the file names.
>> Const FOF_CREATEDIR = 512
>> ' Do not confirm the creation of a new directory if the operation
>> requires
>> one to be created.
>> Const FOF_NOERRORDISPLAY = 1024
>> ' Do not display a user interface if an error occurs.
>> Const FOF_NOSECURITYCOPY = 2048
>> ' Version 4.71. Do not copy the security attributes of the file.
>> Const FOF_NOSUBDIRECTORIES = 4096
>> ' Only operate in the local directory. Don't operate recursively into
>> subdirectories.
>> Const FOF_NOCONNECTEDFILES = 8192
>> ' Version 5.0. Do not copy connected files as a group. Only copy the
>> specified files.
>>
>> Set oSHApp = CreateObject("Shell.Application")
>>
>> sSrc = "c:\testsource\*.*"
>> sDest = "c:\testdest\"
>> set sFolder = oSHApp.NameSpace(sDest)
>>
>> if not sFolder is nothing then
>> sFolder.CopyHere sSrc,FOF_CONFIRMALL
>> end if
>>
>> Set oSHApp = nothing ' clean up
>> WScript.Quit
>
> What OS and what version of vbscript are you using. Did the destination
> folder exist before attempting to copy files to it? AFAIK, CopyHere does
> not
> create the destination folder. By "seems to ignore", what results were you
> expecting from the code above? Was there a large amount of data in the
> source folder to be copied?
>
> --
> Todd Vargo
> (Post questions to group only. Remove "z" to email personal messages)
>
I'm using vbscript version 5.7 on WinXPProSP2.
Yes the folder exists. The copies work fine, the options don't. If I use
this confirmall option, it still prompts me to confirm overwrite when
destination files already exist. If I use the simpleprogress option it
still shows file names.


My System SpecsSystem Spec
Old 08-19-2009   #7 (permalink)
James


 
 

Re: CopyHere

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@xxxxxx> wrote in message
news:%23yWJ$NEIKHA.5256@xxxxxx
Quote:

>
> "Eric" <someone@xxxxxx> wrote in message
> news:eHK7rHEIKHA.1340@xxxxxx
Quote:

>> MS says CopyHere has options.
>> http://msdn.microsoft.com/en-us/libr...66(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!
>

My System SpecsSystem Spec
Old 08-19-2009   #8 (permalink)
James


 
 

Re: CopyHere

The following options work...but I cannot use specify more than one at a
time or the complete copy will fail. Anyone know why?

Const FOF_NOCONFIRMATION = &H10& '(16)Respond with "Yes to All" for any
dialog box that is displayed
Const FOF_SIMPLEPROGRESS = &H100& '(256)Display a progress dialog box but do
not show the file names
Const FOF_NOCONFIRMMKDIR = &H200& '(512)Do not confirm the creation of a new
directory if the operation requires one to be created

objSHApp.Namespace(strDest).CopyHere
strSrcFavs,FOF_NOCONFIRMATION,FOF_SIMPLEPROGRESS,FOF_NOCONFIRMMKDIR

James

"Eric" <someone@xxxxxx> wrote in message
news:eHK7rHEIKHA.1340@xxxxxx
Quote:

> MS says CopyHere has options.
> http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
> I execute it with options and it ignores them. Am I missing something or
> is MS missing something?
>

My System SpecsSystem Spec
Old 08-19-2009   #9 (permalink)
Paul Randall


 
 

Re: CopyHere

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@xxxxxx> wrote in message
news:O4tY2IOIKHA.4004@xxxxxx
Quote:

>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@xxxxxx> wrote in message
> news:%23yWJ$NEIKHA.5256@xxxxxx
Quote:

>>
>> "Eric" <someone@xxxxxx> wrote in message
>> news:eHK7rHEIKHA.1340@xxxxxx
Quote:

>>> MS says CopyHere has options.
>>> http://msdn.microsoft.com/en-us/libr...66(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!
>>
>
>

My System SpecsSystem Spec
Old 08-19-2009   #10 (permalink)
Eric


 
 

Re: CopyHere

If you can specify more than one at a time, you don't pass them as separate
parameters. You have to combine them.
If you want option 8 and option 16 you pass value 24 not 8,16.
This is why the option values are multiplied numbers.

"James" <dontemailme@xxxxxx> wrote in message
news:eLMw0ZOIKHA.3444@xxxxxx
Quote:

> The following options work...but I cannot use specify more than one at a
> time or the complete copy will fail. Anyone know why?
>
> Const FOF_NOCONFIRMATION = &H10& '(16)Respond with "Yes to All" for any
> dialog box that is displayed
> Const FOF_SIMPLEPROGRESS = &H100& '(256)Display a progress dialog box but
> do not show the file names
> Const FOF_NOCONFIRMMKDIR = &H200& '(512)Do not confirm the creation of a
> new directory if the operation requires one to be created
>
> objSHApp.Namespace(strDest).CopyHere
> strSrcFavs,FOF_NOCONFIRMATION,FOF_SIMPLEPROGRESS,FOF_NOCONFIRMMKDIR
>
> James
>
> "Eric" <someone@xxxxxx> wrote in message
> news:eHK7rHEIKHA.1340@xxxxxx
Quote:

>> MS says CopyHere has options.
>> http://msdn.microsoft.com/en-us/libr...66(VS.85).aspx
>> I execute it with options and it ignores them. Am I missing something or
>> is MS missing something?
>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Need help with copyhere VB Script
Re: CopyHere ignores vOptions on Windows PowerShell PowerShell
CopyHere ignores vOptions on Windows PowerShell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46