vbscript删除文件&;远程计算机的文件夹

vbscript删除文件&;远程计算机的文件夹,vbscript,Vbscript,首先,我不是写VBScript的专家 我需要删除远程系统的文件和文件夹,只需单击一次。我试图在VBScript下构建,但不知怎么的,它不起作用。我请求您的帮助,以纠正相同的或与一个新的脚本,帮助我满足要求。在此方面的任何帮助都将不胜感激,提前感谢 以下是: C:\Test-是我要从中删除文件和子文件夹的目录 C:\computerList.txt–是包含所有远程系统IP地址的文本文件 Const strPath = "C:\Test" Set computerList = objfso.Ope

首先,我不是写VBScript的专家

我需要删除远程系统的文件和文件夹,只需单击一次。我试图在VBScript下构建,但不知怎么的,它不起作用。我请求您的帮助,以纠正相同的或与一个新的脚本,帮助我满足要求。在此方面的任何帮助都将不胜感激,提前感谢

以下是: C:\Test-是我要从中删除文件和子文件夹的目录 C:\computerList.txt–是包含所有远程系统IP地址的文本文件

Const strPath = "C:\Test"

Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

Call Search (strPath)
WScript.Echo"Done."

Sub Search(str)
    Do While Not computerList.AtEndOfStream
    strComputer = computerList.ReadLine
        Dim objFolder, objSubFolder, objFile
        Set objFolder = objFSO.GetFolder("\\" & strComputer & "\" & str)
        For Each objFile In objFolder.Files
            If objFile.DateLastModified < (Now() - 0) Then
                objFile.Delete(True)
            End If
        Next
        For Each objSubFolder In objFolder.SubFolders
            Search(objSubFolder.Path)
            ' Files have been deleted, now see if
            ' the folder is empty.
            If (objSubFolder.Files.Count = 0) Then
                objSubFolder.Delete True
            End If
        Next
    loop

End Sub
Const strPath=“C:\Test” 设置computerList=objfso.OpenTextFile(“C:\computerList.txt”,1) Dim objFSO 设置objFSO=CreateObject(“Scripting.FileSystemObject”) 呼叫搜索(strPath) Echo“完成” 子搜索(str) 不要同时使用computerList.AtEndOfStream strComputer=computerList.ReadLine Dim objFolder、objSubFolder、objFile 设置objFolder=objFSO.GetFolder(“\\”&strComputer&“\”&str) 对于objFolder.Files中的每个objFile 如果objFile.DateLastModified<(现在()-0),则 objFile.Delete(True) 如果结束 下一个 对于objFolder.SubFolders中的每个objSubFolder 搜索(objSubFolder.Path) '文件已被删除,现在查看是否 '文件夹为空。 如果(objSubFolder.Files.Count=0),则 objSubFolder.Delete True 如果结束 下一个 环 端接头 问候,,
Balaram Reddy

使用UNC路径时,需要使用文件夹的远程共享名。如果您在远程pc上具有管理员权限,请使用:

Const strPath = "c$\Test"

使用UNC路径时,需要使用文件夹的远程共享名。如果您在远程pc上具有管理员权限,请使用:

Const strPath = "c$\Test"

使用UNC路径时,需要使用文件夹的远程共享名。如果您在远程pc上具有管理员权限,请使用:

Const strPath = "c$\Test"

使用UNC路径时,需要使用文件夹的远程共享名。如果您在远程pc上具有管理员权限,请使用:

Const strPath = "c$\Test"

第一个问题是您的行顺序不正确:

Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
应该是

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)

您在声明objfso之前正在使用它

您的第一个问题是您的行顺序不正确:

Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
应该是

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)

您在声明objfso之前正在使用它

您的第一个问题是您的行顺序不正确:

Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
应该是

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)

您在声明objfso之前正在使用它

您的第一个问题是您的行顺序不正确:

Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
应该是

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set computerList = objfso.OpenTextFile ("C:\computerList.txt", 1)

您在声明objfso之前正在使用它

尝试过,但没有帮助。下面的行似乎有问题:Set computerList=objfso.OpenTextFile(“C:\computerList.txt”,1)尝试过,但没有帮助。下面的行似乎有问题:Set computerList=objfso.OpenTextFile(“C:\computerList.txt”,1)尝试过,但没有帮助。下面的行似乎有问题:Set computerList=objfso.OpenTextFile(“C:\computerList.txt”,1)尝试过,但没有帮助。下面的行似乎有问题:Set computerList=objfso.OpenTextFile(“C:\computerList.txt”,1)