vb.netshall的简单介绍
vb.net shell
Shell恐怕不行·
创新互联公司-专业网站定制、快速模板网站建设、高性价比昭阳网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式昭阳网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖昭阳地区。费用合理售后完善,10多年实体公司更值得信赖。
给你个现成的:
Sub _CMD(ByVal Data As String)
Try
Dim p As New Process()‘用Process就可以
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.CreateNoWindow = True
p.Start()
Application.DoEvents()
p.StandardInput.WriteLine(Data)’这个Data就是cmd命令
p.StandardInput.WriteLine("Exit")‘这个是退出语句
Dim strRst As String = p.StandardOutput.ReadToEnd()’执行完语句后取得显示内容.
p.Close()
Catch ex As Exception
End Try
‘之后就是你自己的代码了...
End Sub
VB.net中的shell在C#中怎么写
下面是例子,或许对你有用:
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
/// summary
/// Shell for the sample.
/// /summary
public class MyProcess
{
// These are the Win32 error code for file not found or access denied.
const int ERROR_FILE_NOT_FOUND =2;
const int ERROR_ACCESS_DENIED = 5;
/// summary
/// Prints a file with a .doc extension.
/// /summary
public void PrintDoc()
{
Process myProcess = new Process();
try
{
// Get the path that stores user documents.
string myDocumentsPath =
Environment.GetFolderPath(Environment.SpecialFolder.Personal);
myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc";
myProcess.StartInfo.Verb = "Print";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
}
catch (Win32Exception e)
{
if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
{
Console.WriteLine(e.Message + ". Check the path.");
}
else if (e.NativeErrorCode == ERROR_ACCESS_DENIED)
{
// Note that if your word processor might generate exceptions
// such as this, which are handled first.
Console.WriteLine(e.Message +
". You do not have permission to print this file.");
}
}
}
public static void Main()
{
MyProcess myProcess = new MyProcess();
myProcess.PrintDoc();
}
}
}
vb.net 中如何显示shell命令后输出的结果.
具体办法你自己想,提供一个可行的解决方案,先将内容输出到文件,然后再显示文件内容即可.
Shell ("at 1.txt") '此语句可将at显示的内容输出到1.txt中
然后把再把1.txt的内容想办法读入datagrid中即可
文章名称:vb.netshall的简单介绍
文章位置:http://myzitong.com/article/hijejo.html