vbs fso跨盘移动文件夹的怪问题
程序员文章站
2022-05-14 21:00:09
跨盘移动文件夹的怪问题 set objfso = createobject("scripting.filesystemobject") objfso.movefolder...
跨盘移动文件夹的怪问题
set objfso = createobject("scripting.filesystemobject")
objfso.movefolder "c:\scripts" , "d:\2"
权限拒绝,但是copy就可以。可以采用变通的办法先复制再删除
========================================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)存在才可以
set objfso = createobject("scripting.filesystemobject")
objfso.movefolder "c:\scripts" , "d:\2"
权限拒绝,但是copy就可以。可以采用变通的办法先复制再删除
========================================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)存在才可以