在服务器端运行批处理文件 [英] Run a batch file on server side

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

问题描述

你好,

我正在创建一个应用程序,该应用程序运行一个批处理文件并创建一个xml文件,作为我用于进一步处理的结果.我的问题是,当我从本地计算机批处理文件运行我的应用程序时,它运行良好,但是当我通过IIS运行它时,出现了提示错误,

它只是一个过程.请启动命令提示符.

我正在使用以下代码.我已授予iis所有许可.

Hello,

I am creating an application which runs a batch file and create an xml file as result which i am using for further processing. My problem is when i am running my application from local machine batch file is running fine,but when i am running it through IIS nohting is happening,

it meance process.start coudn''t start command Prompt.

I am using following code. I have given all permission to iis.

Dim ProcessInfo As Diagnostics.ProcessStartInfo
ProcessInfo = New Diagnostics.ProcessStartInfo("cmd.exe", "/C " + Server.MapPath("~\myScript.bat"))

        Dim Process As New Diagnostics.Process

       ProcessInfo.CreateNoWindow = False
        ProcessInfo.UseShellExecute = False
        Process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal

        Process = Diagnostics.Process.Start(Server.MapPath("~\Spandata\RunSpan.exe"))
       Process.WaitForExit(20000)

        Process.Close()

推荐答案

pratikngajjar写道:
pratikngajjar wrote:


我已授予IIS所有权限.


I have given all permissions to IIS.


我会听你说的.该代码对我来说似乎还可以.

您在事件日志中看到任何错误条目吗?尝试将代码放在try-catch块中,并将异常记录在catch块中.这可能会让您知道为什么代码未执行.

此外,您还可以查看下面的链接,
^ ]


I will take your words. The code also seems okay to me.

Do you see any error entry in the event log? Try putting the code in try-catch block and log the exception in the catch block. This would probably let you know why the code is not executing.

Additionally you may also check the link below,
Google search - run batch file on server asp.net[^]


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

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