打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Process.Start命令行的5种使用方法
Process.Start命令行的5种使用方法
作者:Ilu    来源:乐博网整理     更新时间:2009-9-5

Process.Start命令行的5种使用方法

1. Process.Start 实例

First, here is an example VB.NET program that uses Process.Start to open the file manager on your C:\ drive. When you run this example the root directory folder will open.

Module Module1            Sub Main()            Process.Start("C:\")            End Sub            End Module

Description of the example code. The Main entry point is declared above and it contains a single line of code, which calls the Process.Start Shared method. It passes one parameter to Process.Start, the directory root.

2. Process.Start打开TXT文本文件

Here we see that when you specify a certain file for Process.Start to open, the default Windows file viewer for the file type will open. This is useful for text files, Microsoft Office files, and many other files.

Module Module1            Sub Main() 'vb.net源码和实例,来自乐博网 www.lob.cn            ' Open the file 'example.txt' at the current program's directory.            ' It will appear in the default text file viewer.            Process.Start("example.txt")            End Sub            End Module

Description of the example VB.NET code. The Main entry point subroutine is declared above. It contains a comment and one call to Process.Start. The "example.txt" file must be found in the program's current directory. Notepad or any text viewer will open. This can be useful for "Read Me" files.

Description of file paths. Instead of just passing "example.txt", you could pass "C:\Users\Sam\example.txt" to specify the absolute directory.

3. Process.Start进行google搜索

In many programs, resources can be given to the user in the form of URLs. You can tell Windows to launch a web browser window with a specific URL. All you have to do is send Process.Start the URL. It is important that you do not specify IEXPLORE unless IE is required.

Module Module1            Sub Main()            SearchGoogle("乐博网")            End Sub            ''' <summary>            ''' Open the user's default browser and search for the parameter.            ''' </summary>            Private Sub SearchGoogle(ByVal t As String)            Process.Start("http://www.google.cn/search?q=" & t)            End Sub            End Module

Description of the example subroutines. You can see that the subroutine SearchGoogle() is called with a String parameter. The SearchGoogle function is then run, and it calls Process.Start. The base URL for a Google search is specified. The query string is then set to the parameter.

 

Note on specifying browser executables. Many users and organizations have certain web browsers they use. However, these should be set at the system-level in Windows. Therefore, you shouldn't normally specify IEXPLORE.EXE here.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
[Unity3d]C#调用WINDOWS命令行(CMD)
tcpip详解笔记(7) ping
命令行删除windows系统服务办法一:
C# 关闭计算机
Jetty:基本功能介绍
C# 调用命令行执行Cmd命令的操作
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服