Shell恐怕不行·
創(chuàng)新互聯(lián)長期為上千多家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為獨(dú)山子企業(yè)提供專業(yè)的網(wǎng)站建設(shè)、成都網(wǎng)站制作,獨(dú)山子網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
給你個(gè)現(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)’這個(gè)Data就是cmd命令
p.StandardInput.WriteLine("Exit")‘這個(gè)是退出語句
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();???
}???
}???
}
AppWinStyle.Hide 隱藏窗口并為隱藏的窗口提供焦點(diǎn)。
AppWinStyle.NormalFocus 為窗口提供焦點(diǎn),并以最近的大小和位置顯示窗口。
AppWinStyle.MinimizedFocus 為窗口提供焦點(diǎn),并以圖標(biāo)的形式顯示窗口。
AppWinStyle.MaximizedFocus 為窗口提供焦點(diǎn),并以全屏方式顯示窗口。
AppWinStyle.NormalNoFocus 將窗口設(shè)置為最近的大小和位置。當(dāng)前活動窗口保持焦點(diǎn)。
AppWinStyle.MinimizedNoFocus 以圖標(biāo)的形式顯示窗口。當(dāng)前活動窗口保持焦點(diǎn)。 ***********************你上面用的是AppWinStyle.Hide ,當(dāng)然看不見窗口,應(yīng)該使用AppWinStyle.NormalFocus就可以切換到新打開的程序了