Blogs

  • Browse Blogs
  • My Blog
  • My Updates

Tags Help

  • View as cloud  | list

Similar Entries

photo

OO Lotusscript - A s...

Blog:  Notes Some Fr...
Darren Briaris
Updated 
No Ratings 0     Comments 5
photo

Compile Problem fixe...

Blog:  Jan Schulz
Jan Schulz
Updated 
No Ratings 0     No Comments 0
photo

Sending Designer int...

Blog:  Jan Schulz
Jan Schulz
Updated 
No Ratings 0     Comments 1
photo

I was wrong: plus is...

Blog:  Yellow is the...
Tim Tripcony
Updated 
No Ratings 0     Comments 2
photo

Recompile in 8.0.2

Blog:  Urs Meli
Urs Meli
Updated 
No Ratings 0     No Comments 0

Dogear Bookmarks

PayDirt

Blog Authors:  Brett Patterson  

Previous |  Main  | Next

A Little Teaser

Brett Patterson  |    |  Tags:  lotusscript windows  |  Comments (5)
Retrieve all partition info from any windows server:

 Partition Info:
(A:)  3 1/2 Inch Floppy Drive
(C:)  NTFS  19.99GB (12.56GB Free) 
(D:)  NTFS  39.99GB (5.96GB Free)  Data
(E:)  CD-ROM Disc


This is a function in a script library.  I use a scheduled agent to pull this data daily and write to a notes document.

Sub getPartitionInfo(doc As NotesDocument, strComputer As String)
    Dim strPartition As String
    
    strPartition = ""
    
    On Error Goto errorHandler
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2";)
    Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk",,48)
    Forall objItem In colItems
'This shows the different info you can actually query.
        Print "Caption: " & objItem.Caption
        Print "Description: " & objItem.Description
        Print "DeviceID: " & objItem.DeviceID
        Print "DriveType: " & objItem.DriveType
        Print "FileSystem: " & objItem.FileSystem
        Print "FreeSpace: " & objItem.FreeSpace
        Print "Name: " & objItem.Name
        Print "ProviderName: " & objItem.ProviderName
        Print "Size: " & objItem.Size
        Print "VolumeName: " & objItem.VolumeName
'Check if it's a Disk Drive (thus no memory) and just return it's drive letter and description
        If objItem.DriveType = 2 Or objItem.DriveType = 5 Or objItem.DriveType = 4 Then
            strPartition = strPartition + "(" + objItem.DeviceID + ";)  " + objItem.Description + Chr(13)
        Else
'Show drive letter, description, total memory and remaining memory.
            strPartition = strPartition + "(" + objItem.DeviceID + ";)  " + objItem.FileSystem + _
            "  " + Cstr(Round(objItem.Size/1024/1024/1024,2)) + "GB (" Cstr(Round(objItem.FreeSpace/1024/1024/1024,2)) + _
            "GB Free)  " + objItem.VolumeName + Chr(13)
        End If
    End Forall
    doc.PartitionInfo = strPartition
    
    Exit Sub
    
errorHandler:
    Print "Could not access Partition Info.  Error " & Err & ": " & Error$ + " at line " & Erl
    Exit Sub
    
End Sub

Comments

1 Bruce Currier      Permalink Brett,

I tried to play with this today and have run into a problem. First, I'm primarily an admin, so treat my developement skills accordingly. It runs fine against "localhost", but when I try to run this against my actual windows servers from my workstation, I get "Could not access partition info Error 207 Automation object error at line 12". I'm assuming this is some kind of an access rights issue. Any ideas on how to solve? Line 12 is the set objWMIService line in the getPartitionInfo sub in the script library.

Thanks!
Bruce Currier

2 Brett Patterson      Permalink Yeah, the one thing I forgot to mention is that the agent has to run under the authority of someone with access to that info on the server. This particular agent is signed by a user name that is in our Domain Admin group in AD.

3 Bruce Currier      Permalink I was afraid you were going to say something like that. We're not an AD shop. Oh well, the code is still cool :)

4 Brett Patterson      Permalink You don't have to be an AD shop, but this will only work on Windows OSes. What is required is administrative access to the box you're trying to query. Our Domain Admin group has local admin rights on every machine, that's why I put it there. You just need the admin access.

5 Devin Olson      Permalink That's a nice bit of code there Brett. Very nice indeed.

-Devin.


Previous |  Main  | Next
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About

Tags

A tag is a keyword that is used to categorize an entry. To view the entries with a particular tag, click a tag name or enter a tag in the box.
The tag cloud indicates the frequency of tag use. Popular tags appear darkest. The slider control adjusts how many tags are displayed in the tag cloud.