本文整理匯總了VB.NET中System.Diagnostics.Process.Start方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Process.Start方法的具體用法?VB.NET Process.Start怎麽用?VB.NET Process.Start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Diagnostics.Process
的用法示例。
在下文中一共展示了Process.Start方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Program
' This sample requires a text.txt file file in your documents folder.
' You'll also need to set the startup object in the project to Sub Main.
Imports System.Diagnostics
Imports System.Security
Imports System.ComponentModel
Module Program
Sub Main()
Console.Write("Enter your domain: ")
Dim domain As String = Console.ReadLine()
Console.Write("Enter you user name: ")
Dim uname As String = Console.ReadLine()
Console.Write("Enter your password: ")
Dim password As New SecureString()
Dim key As ConsoleKeyInfo
Do
key = Console.ReadKey(True)
' Ignore any key out of range.
If key.Key >= 33 AndAlso key.Key <= 90 AndAlso key.Key <> ConsoleKey.Enter Then
' Append the character to the password.
password.AppendChar(key.KeyChar)
Console.Write("*")
End If
' Exit if Enter key is pressed.
Loop While key.Key <> ConsoleKey.Enter
Console.WriteLine()
Try
Console.WriteLine(vbCrLf + "Trying to launch NotePad using your login information...")
Process.Start("notepad.exe", uname, password, domain)
Catch ex As Win32Exception
Console.WriteLine(ex.Message)
End Try
Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\"
Try
' The following call to Start succeeds if test.txt exists.
Console.WriteLine(vbCrLf + "Trying to launch 'text.txt'...")
Process.Start(path + "Text.txt")
Catch ex As Win32Exception
Console.WriteLine(ex.Message)
End Try
Try
' Attempting to start in a shell using this Start overload fails. This causes
' the following exception, which is picked up in the catch block below:
' The specified executable is not a valid application for this OS platform.
Console.WriteLine(vbCrLf + "Trying to launch 'text.txt' with your login information...")
Process.Start(path + "Text.txt", uname, password, domain)
Catch ex As Win32Exception
Console.WriteLine(ex.Message)
Finally
password.Dispose()
End Try
End Sub
End Module
示例2: Main
' 導入命名空間
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
Class MyProcess
Public Shared Sub Main()
Try
Using myProcess As New Process()
myProcess.StartInfo.UseShellExecute = False
' You can start any process, HelloWorld is a do-nothing example.
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
' This code assumes the process you are starting will terminate itself.
' Given that is is started without a window so you cannot terminate it
' on the desktop, it must terminate itself or you can do it programmatically
' from this application using the Kill method.
End Using
Catch e As Exception
Console.WriteLine((e.Message))
End Try
End Sub
End Class
End Namespace
示例3: OpenApplication
' 導入命名空間
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
Class MyProcess
' Opens the Internet Explorer application.
Public Sub OpenApplication(myFavoritesPath As String)
' Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe")
' Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath)
End Sub
' Opens URLs and .html documents using Internet Explorer.
Sub OpenWithArguments()
' URLs are not considered documents. They can only be opened
' by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com")
' Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\myPath\myFile.htm")
Process.Start("IExplore.exe", "C:\myPath\myFile.asp")
End Sub
' Uses the ProcessStartInfo class to start new processes,
' both in a minimized mode.
Sub OpenWithStartInfo()
Dim startInfo As New ProcessStartInfo("IExplore.exe")
startInfo.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(startInfo)
startInfo.Arguments = "www.northwindtraders.com"
Process.Start(startInfo)
End Sub
Shared Sub Main()
' Get the path that stores favorite links.
Dim myFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)
Dim myProcess As New MyProcess()
myProcess.OpenApplication(myFavoritesPath)
myProcess.OpenWithArguments()
myProcess.OpenWithStartInfo()
End Sub
End Class
End Namespace 'MyProcessSample
示例4: MainClass
' 導入命名空間
Imports System
Imports System.Drawing
Imports System.Data
Imports System.IO
Imports System.Collections
Imports System.Windows.Forms
Imports System.Xml
Public Class MainClass
Shared Sub Main()
System.Diagnostics.Process.Start("mailto:" & "youremail@yourserver.com")
End Sub
End Class