Re: Dumb question of the day



On Jun 9, 11:01 am, "LJB" <postmaster@[127.0.0.1]> wrote:
"billious" <billious_1...@xxxxxxxxxxx> wrote in message

news:4a2e7cb7$0$32371$5a62ac22@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx







"Dan Payne" <grumpyo...@xxxxxxxxx> wrote in message
news:uwb9ULR6JHA.1092@xxxxxxxxxxxxxxxxxxxxxxx
I have no experience with VB scripting, so of course I was asked to
write one....
Here's the question.
Is there any VB code out there that is available for public use that
would scan directories, and return information such as full path,
extension, owner, file size, etc out there that I could use???  I signed
up for a class on VBscripting, but they have postponed it twice so far
this year, and my deadline is coming up soon.  This is probably the
easiest thing to do, and if it was C or Pascal (showing my age) it would
be easy, but we don't have those compilers available at work....

Thanks for any help, and not laughing too hard...  ;-)

When you come to a fork in the road, take it. - Yogi Berra

*** Sent via Developersdexhttp://www.developersdex.com***

Try alt.msdos.batch.nt.

No doubt with a proper requirements specification a solution could be
easily constructed using DIR and CACLS and a few processing tricks.

I think I got this fromhttp://www.microsoft.com/technet/scriptcenter/guide/sas_fil_lunl.mspx....
Sorry I can't verify that today. Just change the path you want to scan.

Dim arrHeaders(35)

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.NameSpace("C:\scratch")

For i = 0 To 34
   arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next

For Each strFileName In objFolder.Items
   For i = 0 To 34
      Wscript.Echo i & vbTab & arrHeaders(i) & ": " &
objFolder.GetDetailsOf(strFileName, i)
   Next
Next- Hide quoted text -

- Show quoted text -

Not to be a smart ass, but you can do this in PowerShell like this:

#<--- Start Script --------->
$a = Get-Date -format g
$row = 2
$xl = New-Object -c excel.application
$xl.visible = $True
$wb = $xl.workbooks.add()
$sh = $wb.sheets.item(1)
$sh.Range("A1:T1").Font.Bold = $true
$sh.Range("A:A").Font.Bold = $True
$sh.Cells.Item(1, 1) = "Computer Name"
$sh.Cells.Item(1, 2) = "Date Run" + $a
$sh.Cells.Item(1, 3) = "FullName"
$sh.Cells.Item(1, 4) = "Length"
$sh.Cells.Item(1, 5) = "Owner"
$sh.Cells.Item(1, 6) = "Extension"
$sh.Cells.Item(1, 7) = "LastAccessTime"
$sh.Cells.Item(1, 8) = "CreationTime"
$sh.Cells.Item(1, 9) = "Group Access"

# you will need a list of computers, one computer name per line
$computerlist = Get-Content 'c:\scripts\Servers.txt'
foreach ($srv in $computerlist)
{
$sh.Cells.Item($row, 1) = $srv
$response = Get-WmiObject -query "Select * From Win32_PingStatus Where
Address = '$srv'"

if( ($response -eq $null) -or ($response.StatusCode -ne 0)) {
$sh.Cells.Item($row, 2).Font.ColorIndex = 3
$sh.Cells.Item($row, 2) = "Does Not Ping"
$row++
} else { if ($response.TimeToLive -le 64)
{
$sh.Cells.Item($row, 2).Font.ColorIndex = 5
$sh.Cells.Item($row, 2) = "probably is a Unix host"
$row++
} Else {
# Change the path and the extension. If you want all files,
remove the -include *.???
Get-ChildItem -path c:\scripts\ps1 -recurse -include *.ps1 -ea
continue |
foreach {
$file = New-Object -TypeName
System.Management.Automation.PSObject
Add-Member -InputObject $file -MemberType NoteProperty -Name
"FullName" -Value $_.Fullname
Add-Member -InputObject $file -MemberType NoteProperty -Name
"LastAccessTime" -Value $_.LastAccessTime
Add-Member -InputObject $file -MemberType NoteProperty -Name
"LastWriteTime" -Value $_.LastWriteTime
$acl = Get-Acl -Path $_.FullName
Add-Member -InputObject $file -MemberType NoteProperty -Name
"Owner" -Value $acl.Owner
Add-Member -InputObject $file -MemberType NoteProperty -Name
"AccessToString" -Value
$acl.AccessToString
Add-Member -InputObject $file -MemberType NoteProperty -Name
"Group" -Value $acl.Group
$sh.Cells.Item($row, 3) = $_.FullName
$sh.Cells.Item($row, 4) = $_.Length
$sh.Cells.Item($row, 5) = $acl.Owner
$sh.Cells.Item($row, 6) = $_.Extension
$sh.Cells.Item($row, 7) = $_.LastAccessTime
$sh.Cells.Item($row, 8) = $_.CreationTime
$sh.Cells.Item($row, 9) = $acl.Group
$sh.Cells.EntireColumn.AutoFit()

$row++ }


}
}
}

$wb.SaveAs("C:\temp\find_files.xls")
# close and release resources
$wb.close($false)
$xl.quit()
spps -n excel


#---- End Script -------------->
.



Relevant Pages

  • Implementing DLL
    ... The problem is an implementation of a extension for the Active Directory ... Only the Computers Object is to be extended. ... Assembl ... Rufen Sie die LoaderExceptions-Eigenschaft ab, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Excel 2007 - File Open and Repair
    ... PS non of these computers has received the install yet for the sp2 packages. ... system to generate the extension. ... Excel 2007 - File Open and Repair ...
    (microsoft.public.excel.crashesgpfs)
  • Re: Large files being written to c:winnt emp
    ... extension on them (make sure that extensions of known file types is ... >done near these time periods. ... >automatic downloads of the windows updates but even then ... Of 25 computers on a network, ...
    (microsoft.public.win2000.security)
  • Re: AVG disappearing (closing) just before scan end!
    ... > No problems on XP SP2 ... >> Also, today I ran a complete and a selected area test, and when I ... I don't know what's going on with your computers, ...
    (comp.security.misc)
  • Re: AVG disappearing (closing) just before scan end!
    ... > No problems on XP SP2 ... >> Also, today I ran a complete and a selected area test, and when I ... I don't know what's going on with your computers, ...
    (alt.computer.security)