跨盘移动文件夹的怪问题
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:Scripts" , "d:2"
权限拒绝,但是copy就可以。可以采用变通的办法先复制再删除
========================================wmi=================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where name = 'c:Scripts'")
For Each objFolder in colFolders
errResults = objFolder.Rename("d:VBScript")
Wscript.Echo errResults
Next
错误码13,估计是更名的时候不允许ren c:1 d:2这样的格式
========================Shell.Application可以成功====================
Const FOF_CREATEPROGRESSDLG = &H0&
TargetFolder = "c:3"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TargetFolder)
objFolder.MoveHere "d:downloads", FOF_CREATEPROGRESSDLG
但是必须目标文件夹(像本例的是c:3)存在才可以