我正在尝试使用VBScript中的命令提示符复制文件。问题在于delims中的双引号。
我该如何解决这个问题?
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd /k mkdir .\my_Files\ & for /f **"delims="** %%A in (dir /s /b /ta C:\users\desktop\) do (copy '%%A' .\my_Files\)"
答案 0 :(得分:0)
使用“”(双引号)来转义“在VBScript字符串文字中:
>> cmd = "cmd /k mkdir .\my_Files\ & for /f **"delims="** %%A in (dir /s /b /ta C:\users\desktop\) do (copy '%
%A' .\my_Files\)"
>>
Error Number: 1025
Error Description: Expected end of statement
>> cmd = "cmd /k mkdir .\my_Files\ & for /f **""delims=""** %%A in (dir /s /b /ta C:\users\desktop\) do (copy
'%%A' .\my_Files\)"
>>
>> WScript.Echo cmd
>>
cmd /k mkdir .\my_Files\ & for /f **"delims="** %%A in (dir /s /b /ta C:\users\desktop\) do (copy '%%A' .\my_F
iles\)
>>