无法运行批处理文件? [英] Can't run batch file?

查看:145
本文介绍了无法运行批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行批处理文件。但是,当我运行此代码时,我只是得到一个快速的DOS

窗口闪存:


System.Diagnostics.ProcessStartInfo p = new

System.Diagnostics.ProcessStartInfo

(@" C:\ mybat.bat");

System.Diagnostics.Process proc = new System.Diagnostics.Process ();

proc.StartInfo = p;

proc.Start();

proc.WaitForExit();


如果我双击bat文件,我会看到带有输出的DOS窗口和

一切都会执行。如果我打开一个DOS窗口并输入bat文件,

一切正常。该文件修改其他文件。看看

应该修改的文件,我可以看到它不是通过C#代码执行



有什么想法吗?


谢谢,

Brett

I''d like to execute a batch file. However, I just get a quick DOS
window flash when I run this code:

System.Diagnostics.ProcessStartInfo p = new
System.Diagnostics.ProcessStartInfo
(@"C:\mybat.bat");
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = p;
proc.Start();
proc.WaitForExit();

If I double click the bat file, I see the DOS window with output and
everything executes. If I open a DOS window and type in the bat file,
everything works fine again. The file modifies other files. Looking
at the files that are supposed to be modified, I can see it isn''t
executing via the C# code.

Any ideas?

Thanks,
Brett

推荐答案



为什么不只是:


System.Diagnostics.Process.Start((@" C:\ mybat.bat");


Brett Romero写道:

why not just:

System.Diagnostics.Process.Start((@"C:\mybat.bat") ;

Brett Romero wrote:

我想执行批处理文件。但是,我只是快点DOS当我运行此代码时,窗口会闪现

System.Diagnostics.ProcessStartInfo p = new

System.Diagnostics.ProcessStartInfo

(@" C:\ mybat.bat");

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.StartInfo = p;

proc.Start();

proc.WaitForExit();


如果我双击bat文件,我会看到带有输出的DOS窗口和

一切都执行。如果我打开一个DOS窗口并输入bat文件,

一切正常。该文件修改其他文件。看看

应该修改的文件,我可以看到它不是通过C#代码执行



有什么想法吗?


谢谢,

Brett
I''d like to execute a batch file. However, I just get a quick DOS
window flash when I run this code:

System.Diagnostics.ProcessStartInfo p = new
System.Diagnostics.ProcessStartInfo
(@"C:\mybat.bat");
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = p;
proc.Start();
proc.WaitForExit();

If I double click the bat file, I see the DOS window with output and
everything executes. If I open a DOS window and type in the bat file,
everything works fine again. The file modifies other files. Looking
at the files that are supposed to be modified, I can see it isn''t
executing via the C# code.

Any ideas?

Thanks,
Brett



Mi************@gmail.com 写道:

为什么不只是:


System.Diagnostics.Process.Start((@" C:\ mybat .bat");
why not just:

System.Diagnostics.Process.Start((@"C:\mybat.bat") ;



相同的结果 - 快速的DOS窗口闪光但没有运行。


Brett

Same result - quick DOS window flash but nothing runs.

Brett





代码看似正确,


你至少看到了吗?一个shell窗口?

-

-

Ignacio Machin,

ignacio.machin at dot.state .fl.us

佛罗里达州交通局

Brett Romero< ac ***** @ cygen.comwrote in message

新闻:11 ********************** @ i42g2 000cwa.googlegr oups.com ...
Hi,

The code seems correct ,

do you see at least a shell window?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Brett Romero" <ac*****@cygen.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...

我想执行批处理文件。但是,当我运行此代码时,我只是得到一个快速的DOS

窗口闪存:


System.Diagnostics.ProcessStartInfo p = new

System.Diagnostics.ProcessStartInfo

(@" C:\ mybat.bat");

System.Diagnostics.Process proc = new System.Diagnostics.Process ();

proc.StartInfo = p;

proc.Start();

proc.WaitForExit();


如果我双击bat文件,我会看到带有输出的DOS窗口和

一切都会执行。如果我打开一个DOS窗口并输入bat文件,

一切正常。该文件修改其他文件。看看

应该修改的文件,我可以看到它不是通过C#代码执行



有什么想法吗?


谢谢,

Brett
I''d like to execute a batch file. However, I just get a quick DOS
window flash when I run this code:

System.Diagnostics.ProcessStartInfo p = new
System.Diagnostics.ProcessStartInfo
(@"C:\mybat.bat");
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = p;
proc.Start();
proc.WaitForExit();

If I double click the bat file, I see the DOS window with output and
everything executes. If I open a DOS window and type in the bat file,
everything works fine again. The file modifies other files. Looking
at the files that are supposed to be modified, I can see it isn''t
executing via the C# code.

Any ideas?

Thanks,
Brett



这篇关于无法运行批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆