![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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? |
My System Specs![]() |
| | #3 (permalink) |
| | 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! 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 Specs![]() |
| | #4 (permalink) |
| | 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 Quote: > MS missing something? -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
| | #5 (permalink) |
| | 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 Quote: Quote: Quote: > >> is MS missing something? > > Let's have a look at your script! > 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 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 Specs![]() |
| | #6 (permalink) |
| | 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 Quote: Quote: >> >> is MS missing something? >> > >> > Let's have a look at your script! >> 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) > 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
| | #9 (permalink) |
| | 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 Specs![]() |
| | #10 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||