我覺得應該有兩種解決方法
網站建設哪家好,找創新互聯公司!專注于網頁設計、網站建設、微信開發、小程序制作、集團企業網站建設等服務項目。為回饋新老客戶創新互聯還提供了清徐免費建站歡迎大家使用!
1:把patran的安裝路徑添加到系統環境變量的path屬性下;
2:在你的批處理里面改為如下格式,patran完整路徑(如c:\MSC.software\········patran.exe)+ "-sfp patran.ses",也就是下面這種情況試下“c:\MSC.software\········patran.exe -sfp patran.ses -b -ans yes”
一般情況下寧可相信計算機也不要太相信自己。
給你個測試的方法,你可以使用File.Create在你上述認為正確的路徑創建一個文件試試,看是否創建到你想要的地方了。
Shell恐怕不行·
給你個現成的:
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
下面是例子,或許對你有用:
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();???
}???
}???
}