I think you need to add a:
CD = """" & CD & """"
Which will help the string, when interpreted by the batch file, be interpreted as a whole. (You will be passing "C:\Program Files\"
rather than C:\Program Files\
which will be interpreted as a.bat "C:\Program" "Files\"
)
For example:
'Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
CD = """" & fso.GetAbsolutePathName(".") & """"
'Dim WshShell
'Set WshShell=Wscript.CreateObject("Wscript.shell")
'WshShell.run "a.bat " & CD
or:
'Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
'CD = fso.GetAbsolutePathName(".")
CD = """" & CD & """"
'Dim WshShell
'Set WshShell=Wscript.CreateObject("Wscript.shell")
'WshShell.run "a.bat " & CD
or as Ekkehard.Horner and MC ND have pointed out:
'Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
'CD = fso.GetAbsolutePathName(".")
'Dim WshShell
'Set WshShell=Wscript.CreateObject("Wscript.shell")
WshShell.run "a.bat " & """" & CD & """"
As MC ND has used, you could substitute """"
for char(34)
if you think it is easier to read.
To further improve readability as Ekkehard.Horner has suggested, you could create a function:
Function qq(s)
qq = """" & s & """"
End Function
And use as:
'Dim fso: Set fso = CreateObject("Scripting.FileSystemObject")
'CD = fso.GetAbsolutePathName(".")
'Dim WshShell
'Set WshShell=Wscript.CreateObject("Wscript.shell")
WshShell.run "a.bat " & qq(CD)