in

dotNetFreak

Ramblings & Controls from a .NET Addicted Freak!

Kevin Gearing's Blog

Executing the System Information Program

Following up on my last post, it can also be helpful to have the ability to launch the Microsoft System Information program from within your application, so should any users have difficulty they're able to provide you with various information within a couple of clicks...

Imports System.IO
Imports Microsoft.Win32

Private Sub RunSysInfo()

'Try to retrieve the location from the registry

Dim path As String = GetHklmValue("SOFTWARE\Microsoft\Shared Tools\MSINFO", "PATH")

'Try again using a different registry key if the location wasn't found

If path = String.Empty Then

path = Registry.GetHklmValue("SOFTWARE\Microsoft\Shared Tools Location", "MSINFO") If path <> String.Empty Then path += "\MSINFO32.EXE"

End If

'If we have found the location and the program exists, run it

If path <> String.Empty Then

If File.Exists(path) Then

Process.Start(path)

Exit Sub

End If

End If

'Inform the user we were unable to locate the program

MessageBox.Show("Unable to locate the System Information program.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

End Sub

Private Function GetHklmValue(ByVal keyName As String, ByVal subKeyName As String) As String

Try

Return CStr(Registry.LocalMachine.OpenSubKey(keyName).GetValue(subKeyName, ""))

Catch ex As System.Exception

Return String.Empty

End Try

End Function

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  

Protected by FormShield
Refresh
Listen
Please enter the characters shown on the image


Code:


Add
Shopbot
Shopbot

 

 

Copyright ©2004-2007 Kevin Gearing. All Rights Reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems