下面是一个VBScript代码的示例,用于将一个文件复制到另一个位置:

Set objFSO = CreateObject("Scripting.FileSystemObject")
strSourceFile = "C:\Path\To\Source\File.txt"
strDestinationFolder = "C:\Path\To\Destination\Folder\"

' 检查源文件是否存在
If objFSO.FileExists(strSourceFile) Then
    ' 检查目标文件夹是否存在,如果不存在则创建
    If Not objFSO.FolderExists(strDestinationFolder) Then
        objFSO.CreateFolder(strDestinationFolder)
    End If
    
    ' 获取源文件名
    strFileName = objFSO.GetFileName(strSourceFile)
    
    ' 构建目标文件的完整路径
    strDestinationFile = objFSO.BuildPath(strDestinationFolder, strFileName)
    
    ' 复制文件
    objFSO.CopyFile strSourceFile, strDestinationFile
    
    ' 检查目标文件是否复制成功
    If objFSO.FileExists(strDestinationFile) Then
        WScript.Echo "文件复制成功!"
    Else
        WScript.Echo "文件复制失败!"
    End If
Else
    WScript.Echo "源文件不存在!"
End If

请将strSourceFile替换为要复制的源文件的完整路径,将strDestinationFolder替换为要复制到的目标文件夹的完整路径

vbs代码复制文件

原文地址: http://www.cveoy.top/t/topic/h9C3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录