Moving folder in VBscript
There are two methods (filesystemobject and shell) to move folders in VBScript, as someone who is new to scripting please can someone tell me why or when you would use one over the other?
Filesystemobject
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\Scripts" , "M:\helpdesk\management"
Shell
Const FOF_CREATEPROGRESSDLG = &H0&
TargetFolder = "D:\Archive"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TargetFolder)
objFolder.MoveHere "C:\Scripts", FOF_CREATEPROGRESSDLG
Filesystemobject
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\Scripts" , "M:\helpdesk\management"
Shell
Const FOF_CREATEPROGRESSDLG = &H0&
TargetFolder = "D:\Archive"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TargetFolder)
objFolder.MoveHere "C:\Scripts", FOF_CREATEPROGRESSDLG
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
WiseUser
19 years ago
"Shell.Application" is part of "Shell32.dll". This dll is an integral part of windows and would exist whether the scripting host was installed or not. You can be sure that "movefolder" will be available if the scripting host is installed, but I'm not sure all versions of "Shell32.dll" would facilitate moving folders from script (does this work on NT4 or Windows 9x or ME)?
Posted by:
Naffcat
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.