vb.net用shell的簡(jiǎn)單介紹

VB.net中用shell運(yùn)行bat失敗 請(qǐng)教

我覺得應(yīng)該有兩種解決方法

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、小程序制作、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了清徐免費(fèi)建站歡迎大家使用!

1:把patran的安裝路徑添加到系統(tǒng)環(huán)境變量的path屬性下;

2:在你的批處理里面改為如下格式,patran完整路徑(如c:\MSC.software\········patran.exe)+ "-sfp patran.ses",也就是下面這種情況試下“c:\MSC.software\········patran.exe -sfp patran.ses -b -ans yes”

vb.net中用shell調(diào)用外部exe一直報(bào)"未找到文件"的錯(cuò)誤,但是路徑確實(shí)是對(duì)的

一般情況下寧可相信計(jì)算機(jī)也不要太相信自己。

給你個(gè)測(cè)試的方法,你可以使用File.Create在你上述認(rèn)為正確的路徑創(chuàng)建一個(gè)文件試試,看是否創(chuàng)建到你想要的地方了。

vb.net shell

Shell恐怕不行·

給你個(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

VB.net中的shell在C#中怎么寫

下面是例子,或許對(duì)你有用:

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的簡(jiǎn)單介紹
文章網(wǎng)址:http://muchs.cn/article32/doedhpc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站品牌網(wǎng)站設(shè)計(jì)、外貿(mào)建站、網(wǎng)站收錄、小程序開發(fā)云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營