无法通过asp.net中的窗口服务代码运行批处理文件 [英] not able run batch file through window service code in asp.net

查看:51
本文介绍了无法通过asp.net中的窗口服务代码运行批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

 我正在使用代码 到运行批处理是的文件位于指定位置.

 I am using the code  to  run a  batch   file which is  located at specified location.

我正在使用代码

System.Diagnostics.Process进程=新的System.Diagnostics.Process();
                    process.StartInfo =新的System.Diagnostics.ProcessStartInfo(@"d:\ test.bat");
                    process.StartInfo.CreateNoWindow = false;
                    process.StartInfo.ErrorDialog = false;
                    process.StartInfo.RedirectStandardError = true;
                    process.StartInfo.RedirectStandardInput = true;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                    process.Start();

System.Diagnostics.Process process = new System.Diagnostics.Process();
                    process.StartInfo = new System.Diagnostics.ProcessStartInfo(@"d:\test.bat");
                    process.StartInfo.CreateNoWindow = false;
                    process.StartInfo.ErrorDialog = false;
                    process.StartInfo.RedirectStandardError = true;
                    process.StartInfo.RedirectStandardInput = true;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                    process.Start();

此代码运行通常当我使用时它在简单的网页,但是当我使用时这个内部我的窗口服务它无需运行任何 效果.我无法到 对此排序问题.

This code run   normally   when i use  it in  simple web page, but  when i use  this  inside  my  window  services  it  run without  any  effect.  I Am not able  to sort this  issue.

是IT 与安全许可有关的任何问题,如果是的,那么它需要提供访问权限的地方许可.

Is IT  any issue related to security permission ,if  yes then where it needs to provide access  permission.

请提出建议.

rishi [URL = http://miniclipgames.name/] miniclip [/URL],[URL = http://www.btjunkie.name/] btjunkie [/URL],[URL = http://www.freedownloadgames.name/]游戏[/URL]

rishi [URL=http://miniclipgames.name/ ]miniclip[/URL], [URL=http://www.btjunkie.name/ ]btjunkie[/URL], [URL=http://www.freedownloadgames.name/ ]games[/URL]

推荐答案

您不需要外壳执行为true即可创建cmd.exe的新副本吗?

Do'nt you need the shell execute to be true to create a new copy of cmd.exe?

  process.StartInfo.UseShellExecute = true;

 process.StartInfo.UseShellExecute = true;

您是否将输入和输出管道输送到外壳copmmand?您同时具有标准输入和标准输出,并且标准错误设置为true.如果bat文件文件有任何输入或输出,则如果您不将任何内容连接到管道,它将被阻止. 您可能需要向标准输出和标准错误中添加流,以便可以看到任何错误消息.

Are you piping inputs and output to the shell copmmand? You have both standard input and standard output and standard error set true.  If the bat file file has any input or ouput it will be blocked if you don't connect anything to the pipes.  You may want to add a stream to the standard output and standard error so you can see any error messages.


这篇关于无法通过asp.net中的窗口服务代码运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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