Problem copying files through xcopy using VBScript
Posted
by sushant
on Stack Overflow
See other posts from Stack Overflow
or by sushant
Published on 2010-03-19T06:12:16Z
Indexed on
2010/03/22
1:41 UTC
Read the original article
Hit count: 514
I am using VBScript to copy files using xcopy. The problem is that the folder path has to be entered by the user. Assuming I put that path in a variable, say h
, how do I use this variable in the xcopy command?
Here is the code I tried:
Dim WshShell, oExec, g, h
h = "D:\newfolder"
g = "xcopy $h D:\y\ /E"
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec(g)
I also tried &h
but it did not work. Could anyone help me work out the correct syntax? Any help is appreciated.
© Stack Overflow or respective owner