vb.net用shell的简单介绍
VB.net中用shell运行bat失败 请教
我觉得应该有两种解决方法
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、小程序制作、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了清徐免费建站欢迎大家使用!
1:把patran的安装路径添加到系统环境变量的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调用外部exe一直报"未找到文件"的错误,但是路径确实是对的
一般情况下宁可相信计算机也不要太相信自己。
给你个测试的方法,你可以使用File.Create在你上述认为正确的路径创建一个文件试试,看是否创建到你想要的地方了。
vb.net shell
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
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的简单介绍
当前地址:http://pwwzsj.com/article/doedhpc.html