0

我试图让这个脚本工作,它获取 4 个参数并结束重命名文件夹(FDirectory)删除空格并使用新参数启动一个批处理文件。问题是它为包含只读文件的文件夹返回错误“访问被拒绝”。有没有办法让它工作?提前致谢。

  Set WshShell = CreateObject("WScript.Shell")

  currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
  length = Len(currentDirectory)

  State = WScript.Arguments.item(0)
  Directory = Left(WScript.Arguments.item(1),length+6)
  FDirectory = Replace(WScript.Arguments.item(1)," ",".")
  Kind = WScript.Arguments.item(2)
  Message = WScript.Arguments.item(3)

  'change folder name
  If (kind = "multi") And (Directory = currentDirectory & "SFetch") then
  Set FS = CreateObject("Scripting.FileSystemObject")
  FS.MoveFolder WScript.Arguments.item(1),Replace(WScript.Arguments.item(1)," ",".")
  END IF

  currentDirectory = currentDirectory & "Rename.bat "

  WshShell.RUN currentDirectory & State & " " & Directory & " " & FDirectory & " " & Kind & " " & Message, 0, True
  Set WshShell = Nothing
4

1 回答 1

0

只读文件不会产生问题 - 但是重命名其中包含打开文件的文件夹,或重命名当前工作目录会产生问题。

于 2013-11-09T12:11:45.830 回答