在實際應用中,發(fā)現了一個問題,vbs跨盤移動文件夾無權限,權限拒絕,但是copy就可以??梢圆捎米兺ǖ霓k法先復制再刪除
跨盤移動文件夾的怪問題
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\Scripts" , "d:\2"
權限拒絕,但是copy就可以??梢圆捎米兺ǖ霓k法先復制再刪除
===========================wmi==============================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
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)存在才可以