script share folders

Scriptin’ 7

 

 

‘VBScript

‘Get list of shares

‘Scripting domain computes share folders

On Error Resume Next
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set objInputFile = fso.OpenTextFile(“comps.txt”, 1, True)
Set objOutputFile = fso.OpenTextFile(“vystup.txt”, 8, True)

Do While objInputFile.AtEndOfLine <> True

strComputer = objInputFile.ReadLine
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

Set colItems = objWMIService.ExecQuery(“SELECT * FROM Win32_ComputerSystem”)
Set colShares = objWMIService.ExecQuery _
(“Select * from Win32_Share”)

For Each objItem In colItems
ObjOutputFile.WriteLine “Computer Name: ” & strComputer
Next
For Each objShare in colShares
ObjOutputFile.WriteLine objShare.Path & vbNewLine
Next
Loop