【发布时间】:2009-09-09 10:04:19
【问题描述】:
我需要以下代码方面的帮助。 我尝试将 AutoCAD 文件从 dwg 格式转换为 dwf 格式。 然后,下载 dwf 文件并使用 java 小程序在客户端计算机上打开。
用于在命令行转换dwg文件的命令是: C:\inetpub\wwwroot\COR-Basic\cadviewer\converter\ax2008.exe -i="C:\inetpub\wwwroot\test\container\DU38_EG00_070116.dwg" -o="C:\inetpub\wwwroot\COR- Basic\cadviewer\files\DU38_EG00_070116.dwf" -f=dwf -model -text
这在我在 cmd.exe 中输入命令文本时有效。
但是当我从我的 asp.net 应用程序中调用它时,它只会启动进程,但进程永远不会结束......
我已尝试添加其他用户,已授予该用户完全权限,以及对 wwwroot 的完全权限,但仍然无法正常工作。
任何人都知道我做错了什么,或者我怎么能以另一种方式做到这一点?
If System.IO.File.Exists(strDWGlocation) Then
Dim psiProcessSettings As Diagnostics.ProcessStartInfo = New Diagnostics.ProcessStartInfo
psiProcessSettings.FileName = strApplicationPath
psiProcessSettings.Arguments = " -i=""" & strDWGlocation & """ -o=""" & strOutputLocation & """ -f=dwf -model -text"
'ST-LAPTOP\converter
psiProcessSettings.UserName = "converter"
psiProcessSettings.Password = secureString
'StefanSteiger.Debug.MsgBox("Input location:" + strDWGlocation)
'StefanSteiger.Debug.MsgBox("Output location:" + strOutputLocation)
Response.Write("<h1>Argument1: " + psiProcessSettings.Arguments + "</h1>")
Response.Write("<h1>Pfad1: " + psiProcessSettings.FileName + "</h1>")
'psiProcessSettings.RedirectStandardInput = True
psiProcessSettings.RedirectStandardError = True
psiProcessSettings.RedirectStandardOutput = True 'Redirect output so we can read it.
psiProcessSettings.UseShellExecute = False 'To redirect, we must not use shell execute.
'psiProcessSettings.CreateNoWindow = True ' don't create a window
Dim pConverterProcess As Diagnostics.Process = New Diagnostics.Process
pConverterProcess = Diagnostics.Process.Start(psiProcessSettings) 'Create the process.
pConverterProcess.Start() 'Execute the process.
'Response.Write("<h1>" + Replace(pConverterProcess.StandardOutput.ReadToEnd(), vbCrLf, "<BR />") + "</h1>") 'Send whatever was returned through the output to the client.
'pConverterProcess.CancelOutputRead()
'pConverterProcess.CancelErrorRead()
'pConverterProcess.StandardInput.Close()
'Wait for the process to end.
'pConverterProcess.WaitForExit()
pConverterProcess.Close()
'Dim iExitCode As Integer = pConverterProcess.ExitCode()
pConverterProcess.Dispose()
Else
MyNamespace.Debug.MsgBox("No such file.")
End If
【问题讨论】:
-
你应该向 ax2008 的创建者询问这个问题。特别是,应用程序在启动时是否显示任何 UI?
-
不,它不是,它是一个命令行实用程序。而且它不要求输入,你只需要输入命令行参数然后回车。
标签: asp.net shell process executable