Shell恐怕不行·

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比昭陽網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式昭陽網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋昭陽地區(qū)。費用合理售后完善,10多年實體公司更值得信賴。
給你個現(xiàn)成的:
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()’執(zhí)行完語句后取得顯示內(nèi)容.
p.Close()
Catch ex As Exception
End Try
‘之后就是你自己的代碼了...
End Sub
下面是例子,或許對你有用:
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();???
}???
}???
}
具體辦法你自己想,提供一個可行的解決方案,先將內(nèi)容輸出到文件,然后再顯示文件內(nèi)容即可.
Shell ("at 1.txt") '此語句可將at顯示的內(nèi)容輸出到1.txt中
然后把再把1.txt的內(nèi)容想辦法讀入datagrid中即可
當(dāng)前標(biāo)題:vb.netshall的簡單介紹
標(biāo)題路徑:http://chinadenli.net/article20/hijejo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、Google、靜態(tài)網(wǎng)站、App設(shè)計、網(wǎng)站改版、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)