Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell XCopy fails 1

Status
Not open for further replies.

waytech2003

Programmer
Jul 14, 2003
316
US
I have tried to use the Xcopy in a shell and it does not work. No errors, just no results. It works right in win98 and ME, but not in XP. I know I could use FSO, but just wondering why it will not work in XP. I have only tested in XP home, not XP pro

Source="C:\Program Files\ProgramName\Records.data"
Shell "Xcopy " & Source & " C:\DataBackup\ ", VBNormal
Shell "Xcopy " & Source & " C:\DataBackup\*.* ", VBNormal
 
You could just use the VB6 native Filecopy statement which still works under XP

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Source" has a value containing a space?

[tt]Shell "Xcopy """ & Source & """ C:\DataBackup\ ", VBNormal[/tt]
 
johnwm

Yes for single file copy that would work. I need to use wildcards in my program to copy many files.

dilettante

I tried a test.

Shell "Xcopy C:\TEST1\Records.data C:\DataBackup\Records.data", VBNormal

And that failed to copy too.
 
I should have explained further! Use the Dir function with the wildcards, use the filecopy on the results of Dir then loop until done.

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
I think you will probably need to run your xcopy from with an instance of cmd. So you will need something like;

Shell "cmd /c Xcopy blah blah"

Sorry I can't test it right now because i'm away fro home on an Apple system.

regards Hugh,
 
johnwm
I will look into that, but still would like to know why XCopy works correctly on prior Windows but not XP.

HughLerwill
Just tried with CMD and it's still the same results
 
Home again!

Think failure could be down to spaces in your path names; this is now working for me;

Shell "Cmd /c xcopy " & Chr$(34) & App.Path & "\*.*" & Chr$(34) & " " & Chr$(34) & App.Path & "\NewFolder" & Chr$(34)

Not tested without the Cmd /c prefix but may be worth a try.

HTH Hugh,
 
Yes;

Shell "xcopy " & Chr$(34) & App.Path & "\*.*" & Chr$(34) & " " & Chr$(34) & App.Path & "\NewFolder" & Chr$(34)

is working too!
 
HughLerwill
Copied and pasted your shell example.
This works, now I just need to set the proper flags and I'm go to go.

Thanks All
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top