Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1271
  • Last Modified:

Get MSInfo report in Visual Basic

I'm gathering a series of logs for debugging purposes and I want to collect the MSInfo report. I figured the only way I could do this is to run it in a shell and then collect the resulting NFO file.

My problem appears to be in my implementation. Visual Studio complains:
Process '3516' was not found.

This is all Greek to me and I would love some help either getting my code working, or finding a better way to get a MSInfo32 report written to disk.
If CheckBoxSystemProfile.CheckState = CheckState.Checked Then
            Dim strCommand As String
            Dim retPointer As Integer
            Dim millisecondsTimeout As Integer
            millisecondsTimeout = 60000
 
            retPointer = Shell("cmd.exe", AppWinStyle.MaximizedFocus)
 
            AppActivate(retPointer)
 
            strCommand = "C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32 /report C:\System.nfo"
            SendKeys(strCommand, True)
            SendKeys("{ENTER}", True)
            SendKeys("EXIT", True)
            SendKeys("{ENTER}", True)
 
            System.Threading.Thread.Sleep(millisecondsTimeout)
 
            srcFolderList.Add("C:\System.nfo")
        End If

Open in new window

0
Syncer
Asked:
Syncer
  • 7
  • 4
1 Solution
 
SyncerAuthor Commented:
Nobody? Upping the points.
0
 
Bob LearnedCommented:
I don't need no stinkin' points--it is about the challenge.  What kind of information are you after?  Could you get that information with WMI?
0
 
SyncerAuthor Commented:
I need the system summary, installed applications and their version information, and running processes.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Bob LearnedCommented:
What installed applications?  I don't see how you can get that from MSInfo32...
MSInfo32----Startup-Programs.png
0
 
SyncerAuthor Commented:
MSInfo does list installed applications somewhere, and drivers. The biggest thing I care about are the system profile (windows version, ram, hard disk, etc) and running processes.
0
 
Bob LearnedCommented:
You should be able to get that kind of information with System.Management namespace (WMI) and the System.Diagnostics namespace (Process).

Proof-of-concept:

Get System Information Using WMI in VB.NET
http://www.freevbcode.com/ShowCode.asp?ID=4571
0
 
SyncerAuthor Commented:
WMI won't allow me to get a list of installed drivers (something that's really important)
0
 
Bob LearnedCommented:
Is this VB6 or VB.NET?


VB.NET:
 
  Public Shared Function GetMSInfo() As String
        Dim process As New Process()
 
        Dim outputFileName As String = "C:\temp\System.txt"
 
        process.StartInfo.FileName = "C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe"
        process.StartInfo.Arguments = "/report " & outputFileName
        process.StartInfo.UseShellExecute = False
        process.Start()
 
        process.WaitForExit()
 
        Dim reportText As String = IO.File.ReadAllText(outputFileName)
 
        IO.File.Delete(outputFileName)
 
        Return reportText
    End Function

Open in new window

0
 
SyncerAuthor Commented:
VB.NET
0
 
SyncerAuthor Commented:
I may have spoken too soon, it appear that the process isn't outputting the file. I get an error at Dim reportText As String = IO.File.ReadAllText(outputFileName) that part of the path could not be found.
0
 
SyncerAuthor Commented:
I just changed the path to "C:\System.nfo" and that works. Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now