Sasstraliss
Programmer
Alright. I am looking for a script that logs all files, folders, and subfolders (and sub files) of any drive on a remote computer.
I found a script that does it, BUT it does not do sub directories or folders.
I also found another script that does sub folders, and does everything I want, however it does not work remotely, and this is because strComputer is not justified later on in the script.
If someone can help me get a working script that logs files, folders, and SUB FOLDERS/FILES remotely, then this would be very greatly appreciated.
Thankyou in advance.
I found a script that does it, BUT it does not do sub directories or folders.
Code:
strComputer = (InputBox(" Computer name:", "Z Basic"))
If strComputer <> "" And strComputer <> "q" And strComputer <> "e" Then
Const ForAppending = 2
LogFile = "Z:\Documents\Op. S 2.1\zz--Collected Data\Map Logs\Z-Basic.log"
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='Z:\'} Where " _
& "ResultClass = CIM_DataFile")
For Each objFile In colFileList
objLogFile.Write objFile.Name
objLogFile.Writeline
Next
objLogFile.Close
End if
I also found another script that does sub folders, and does everything I want, however it does not work remotely, and this is because strComputer is not justified later on in the script.
Code:
strComputer = (InputBox(" Computer name:", "Z Adv"))
If strComputer <> "" And strComputer <> "q" And strComputer <> "e" Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 2
Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
LogFile = "Z:\Zzz.log"
Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)
objStartFolder = "Z:\"
Set objFolder = objFSO.GetFolder(objStartFolder)
objLogFile.Write objFolder.Path
objLogFile.Writeline
Set colFiles = objFolder.Files
For Each objFile in colFiles
objLogFile.Write objFile.Name
objLogFile.Writeline
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
objLogFile.Write Subfolder.Path
objLogFile.Writeline
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
objLogFile.Write objFile.Name
objLogFile.Writeline
Next
ShowSubFolders Subfolder
Next
End Sub
objLogFile.Close
End if
If someone can help me get a working script that logs files, folders, and SUB FOLDERS/FILES remotely, then this would be very greatly appreciated.
Thankyou in advance.