无法打开批处理文件.. [英] Unable to open batch file ..

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

问题描述

我有一个我在iis上托管的网络应用程序(os:xp)。



每件事情都运转正常,但一页上有问题。 。



点击我试图调用批处理文件..在批处理文件中我设置了一个UploadSell.dtsx文件来执行..



但是我点击按钮时没有执行UploadSell.dtsx文件..



注意:此代码有效当我在Visual Studio中运行我的应用程序时很好..但是当在iis中托管应用程序时无法打开UploadSell.dtsx文件



这是我的按钮点击代码:

  string  sFileName =   c:\\uploadsell.bat; 
if (File.Exists(sFileName))
{
System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(sFileName);
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = sFileName;
proc.StartInfo.RedirectStandardError = true ;
proc.StartInfo.RedirectStandardOutput = true ;
proc.StartInfo.UseShellExecute = false ;
proc.Start();
proc.WaitForExit();
lblErrorMsg.Text = 上传记录..;
CT.MessageBox( this 请单击Execute package utility窗口中的EXECUTE按钮并等待上传数据..);
}
else
{
CT.MessageBox( this 抱歉无法处理您的请求...);
lblErrorMsg.Visible = false ;
}

解决方案

在IIS(或大多数其他合理的Wen浏览器)下执行的Web应用程序不会处理文件这样的路径名称。 HTTP服务器在一些沙盒环境中执行服务器端代码,这是安全的。它只能在与特定网站关联的根目录下使用文件。如果相应地更改了文件位置,则可以使代码正常工作。



重要说明:更一般地说,没有硬编码路径名可以的情况有用。无论您的项目是什么类型的应用程序,都应根据环境和配置信息,用户数据等在运行时计算所有路径名。



-SA

i have a web app which i have hosted on iis(os:xp).

Every thing is working fine but there is a problem on one page..

on butten click i am trying to call batch file..and in batch file i have set an UploadSell.dtsx file to execute..

but UploadSell.dtsx file is not executing when i click on button..

NOTE: This code works fine when i run my app in Visual studio .. But unable to open UploadSell.dtsx file when app is hosted in iis

Here are my button click code:

string sFileName ="c:\\uploadsell.bat";
      if (File.Exists(sFileName))
            {
                System.Diagnostics.ProcessStartInfo p = new System.Diagnostics.ProcessStartInfo(sFileName);
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName = sFileName;
                proc.StartInfo.RedirectStandardError = true;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.UseShellExecute = false;
                proc.Start();
                proc.WaitForExit();
                lblErrorMsg.Text = "Uploading Records..";
                CT.MessageBox(this, "Please click on EXECUTE Button in Execute package utility window and wait to upload data..");
            }
            else
            {
              CT.MessageBox(this, "Sorry unable to process you request...");
              lblErrorMsg.Visible = false;
            }

解决方案

A Web application executing under IIS (or most other reasonable Wen browsers) won''t handle files with such path name. HTTP servers execute server-side code in some sandboxed environment, which is safe. It can use files only under the root directory associated with a particular Web site. If you change the file location accordingly, you can make your code working.

An important note: more generally, there are no situations where hard-coded path names can be useful. No matter what kind of application is your project, all path names should be calculated during run time based on environment and configuration information, user data, etc.

—SA


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

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