Vbscript VBS告诉我对象没有';我不支持这个属性

Vbscript VBS告诉我对象没有';我不支持这个属性,vbscript,create-directory,Vbscript,Create Directory,我真的不知道怎么了,有人能帮我吗: Dim objFSO, objFolder, objFile, objNewFolder ' Create the file system object/Assing the system object to a variable Set objFSO = CreateObject("Scripting.FileSystemObject") ' Get the folder we want to copy files from Set objFSO =

我真的不知道怎么了,有人能帮我吗:

Dim objFSO, objFolder, objFile, objNewFolder

' Create the file system object/Assing the system object to a variable 
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Get the folder we want to copy files from 
Set objFSO = objFSO.GetFolder("C:\Test")

' Create a new folder called Test2 
Set objNewFolder = objFSO.CreateFolder("C:\Test\Test2")

' For each file in the folder, copy the file to the destination 
For Each objFile In objFolder.Files 
    objFile.Copy "C:\Test2" 
Next 
它告诉我:

vbs对象不支持此属性或方法:“CreateFolder”


问题在于,您正在重新分配
objFSO
以成为此处返回的
文件夹
对象:

Set objFSO = objFSO.GetFolder("C:\Test")
在这一行之后,
objFSO
不再是
Scripting.FileSystemObject
,而是
Scripting.Folder
对象。您需要将代码更改为:

Set objFolder = objFSO.GetFolder("C:\Test")