Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '------------------------------------------------------------------------------------------
- ' Notice of My Copyright and Intellectual Property Rights
- '
- ' Any intellectual property contained within the program by Joseph L. Bolen remains the
- ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
- ' publish or provide such intellectual property to any other person or entity for any
- ' reason, commercial or otherwise, without the express written permission of Joseph L. Bolen.
- '
- ' Copyright © 2015. All rights reserved.
- ' All trademarks remain the property of their respective owners.
- '-------------------------------------------------------------------------------------------
- ' Program Name: Process Command Demo
- '
- ' Author: Joseph L. Bolen
- ' Date Created: Dec 2015
- '
- ' Description: Issues the MsConfig program from a Visual Basic program.
- '
- ' Compiling Note: Change program to Compile Target CPU - x64 (or uncheck Prefer 32-bit).
- '-------------------------------------------------------------------------------------------
- Imports System.IO
- Public Class MainlineForm
- Private Sub startProcessButton_Click(sender As Object, e As EventArgs) _
- Handles startProcessButton.Click
- ' Quick and dirty approach ...
- 'Try
- ' Process.Start("msconfig.exe") ' Path is assumed.
- 'Catch ex As Exception
- ' MessageBox.Show(ex.Message,
- ' "Process Error",
- ' MessageBoxButtons.OK,
- ' MessageBoxIcon.Error)
- 'End Try
- ' More sophisticated approach ...
- Dim pgmFilePath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "msconfig.exe")
- Dim myProcess As New Process ' System.Diagnostics namespace
- With myProcess.StartInfo
- .FileName = pgmFilePath
- .UseShellExecute = True
- .Verb = "runas"
- .WindowStyle = ProcessWindowStyle.Normal
- End With
- Try
- myProcess.Start()
- myProcess.WaitForExit()
- Catch ex As Exception
- MessageBox.Show(ex.Message,
- "Process Error",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error)
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement