asp.netのサーバー側でバッチファイルを実行したいので、次のコマンドを使用してバッチファイルを実行しました。デバッグ モードで実行しているときは正常に動作していますが、URL をホストしてバッチ ファイルを呼び出すと、動作しません。
protected void Button1_Click(オブジェクト送信者, EventArgs e) {
try
{
if (FileUpload1.FileName == "")
{
Label1.Visible = true;
Label1.Text = "Browse Respective text file";
return;
}
if ((File.Exists(Server.MapPath("~/DND_BASE/" + FileUpload1.FileName))) == true)
{
Label1.Visible = true;
Label1.Text = "File Name already Uploaded";
return;
}
else
{
string DestFilepath = @"D:\124_SMS_DATA\124_SMS_Base\"+FileUpload1.FileName;
string SrcFilepath = Server.MapPath("~/DND_BASE/") + FileUpload1.FileName;
FileUpload1.SaveAs(System.IO.Path.Combine(Server.MapPath("~/DND_BASE/"), FileUpload1.FileName));
if (File.Exists(DestFilepath))
{
File.Delete(DestFilepath);
}
File.Move(SrcFilepath, DestFilepath);
Label5.Visible = true;
Label5.Text = "File Uploaded Successfully You can download file after 5 Mins";
string path = Server.MapPath(".") + "\\test.bat";
System.Diagnostics.Process.Start(path);
}
}
catch(Exception ex)
{
err = new ErrorHandler();
err.WriteToErrorLog(ex.Message.ToString());
}
}