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.