-----copyfiles.vbs----
------Dim nodeNameDim argsObjSet argsObj=WScript.ArgumentsIf argsObj.Count=1 ThennodeName = argsObj(0)ElseWScript.echo "usage: cscript.exe copyfiles.vbs <nodeName>"WScript.Quit (1)End IfSet objWMIService = GetObject _("winmgmts:\\" & nodeName & "\root\cimv2:Win32_Process")errReturn = objWMIService.Create _("cmd.exe /c md c:\Temp", Null, Null, intProcessID)Wscript.Echo errReturnsSet objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & nodeName & "\root\cimv2")Set colFiles = _objWMIService.ExecQuery("Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\Scripts\\' and FileName Like 'coda%'")'Wscript.Echo colFiles.Count echo number of filesFor Each objFile in colFilesstrNewFile = "C:\Temp\" & objFile.FileName & "." & objFile.ExtensionerrResults = objFile.Copy(strNewFile)Wscript.Echo errResults 'displaying error codeNext
This script allow copy selected files on a remote machine
usage : cscript copyfiles.vbs computername
Notes:
The script is doing the following:
- Create Folder Named C:\temp this done by this statement " ("cmd.exe /c md c:\Temp", Null, Null, intProcessID)
- Select files located on drive C: on folder named \scripts\ and all files starts with coda this is done by " objWMIService.ExecQuery("Select * From CIM_DataFile Where Drive = 'C:' and Path = '\\Scripts\\' and FileName Like 'coda%'") "
- Writes those files into folder c:\temp “strNewFile = "C:\Temp\" & objFile.FileName & "." & objFile.Extension “