【发布时间】:2014-06-17 08:46:28
【问题描述】:
.NET 应用程序,我想执行一个 exe。
到这个exe:
这个 exe 文件是一个显示许可用户的程序。
我在我的开发虚拟机上使用 Visual Studio 2010 对其进行了测试,它可以工作,但如果我将它部署在我的网络服务器上的 iis7 上,它就无法工作。错误是:
错误:无法创建 qrun.inf 文件
有什么问题?为什么应用不能创建文件?
这是我的代码:
Web.Config:
...
<setting name="LSDYNA_CMD" serializeAs="String">
<value>~\\exe\\lstc_qrun.exe -s lwserv-lic -R</value>
</setting>
...
exe在我的exe文件夹中
我在这里得到值:
string cmd = Properties.Settings.Default.LSDYNA_CMD;
cmd = Server.MapPath(cmd);
string output = ExecuteCommand(cmd);
...
这里是ExecuteCommand(..) 方法
public static string ExecuteCommand(string command)
{
int exitCode;
ProcessStartInfo processInfo;
Process process;
try
{
processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
using (process = Process.Start(processInfo))
{
string output = process.StandardOutput.ReadToEnd();
exitCode = process.ExitCode;
return output;
}
}
catch (Exception ex)
{
return "error: " + ex.Message;
}
}
我直接在网络服务器上尝试它,我得到了列表 (O.o) 我打开了一个 cmd 并在其中创建了命令。
我需要帮助我不知道该怎么做:(
【问题讨论】:
-
只有我看到这个会紧张吗?
-
应该是权限/权限问题。你试过以管理员身份运行吗?
-
创建qrun.inf文件的路径是什么?
-
路径是exe文件所在的位置。 ...文件夹 exe --> C:\inetpub\wwwroot\licreader\exe
-
我可以使用临时文件夹来创建文件吗?
标签: c# asp.net file process exe