I don't think you can make it work that way: the & operator is part of the command-line shell, not of the CreateProcess or ShellAPI frameworks.
I see several ways to work around this:
- call CMD.exe and pass your command-line as parameter. (i.e. "%ComSpec% /c " & Stuff)
- Write a batch on the fly and execute it.
- Just write two calls to WshShell.Exec instead of one. It's probably better since you can check the result of each individual part of the process anyway. You can even do the copy in script instead of calling xcopy for extra error checking and loging.
here is a sample code on how to copy a folder and then tzip another one in VBScript:
Dim WshShell, oExec, oFS, oF
szSourcePath="c:\tmp\testfolderSrc"
szDestinationPath="c:\tmp\testfolderDest"
szDestinationZip="c:\tmp\final.zip"
bOverwrite=true
' Create objects
Set oFS = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
' cleanup target folder
if oFS.FolderExists(szDestinationPath) then
oFS.DeleteFolder szDestinationPath, true
end if
' Create target folder
set oF = oFS.CreateFolder(szDestinationPath)
' Copy content of the source folder to the target folder
oFS.CopyFolder szSourcePath & "\*", szDestinationPath, bOverwrite
' delete old zip
if oFS.FileExists("c:\myzip.zip") then
oFS.deleteFile("c:\myzip.zip")
end if
wshShell.CurrentDirectory = "c:\tmp\" ' set current directory to this
Set oExec = WshShell.Exec("c:\program files\winzip\winzip32.exe -min -a c:\myzip.zip" )
Do While oExec.Status = 0
WScript.Sleep 100
Loop