"The system cannot find the file specified" 错误 运行 Ant 来自 VB.NET
"The system cannot find the file specified" error running Ant from VB.NET
我正在尝试通过 VB 项目使用 Apache Ant 运行 Python 应用程序 word2html
。以下代码调用了可执行文件。
//in loop
If (Not ExecuteProgram("ant", "word2html", True)) Then
Throw New System.Exception("couldn't run word2html")
End If
//executeprogram function
Public Function ExecuteProgram(ByVal ExeLoc As String, ByVal ExeArgs As String, ByVal bSynch As Boolean) As Boolean
'The exefile location is passed in along with a boolean value of whether to
'execute the file syncronously or asynchronously
Try
Dim MyInstance As New System.Diagnostics.Process
Dim si As New ProcessStartInfo(ExeLoc, ExeArgs)
MyInstance.StartInfo = si
MyInstance.Start()
If bSynch Then
'run synch
MyInstance.WaitForExit()
End If
Return True
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
End Function
几周前代码 运行 成功,但现在失败了 error message:
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at ConsoleApplication1.Hello.ExecuteProgram(String ExeLoc, String ExeArgs, Boolean bSynch)
in
C:\Users\shwang\Desktop\svn\trunk\data\data_loading\scripts\data_sheet
_scripts\Pipeline\ProcessDatasheetPipeline\Module1.vb:line 349
当我从 cmd
window 运行 ant word2html
时,它 运行 成功了。
我怀疑是我的工作环境发生了变化 我已经检查了 ANT_HOME
和 JAVA_HOME
变量是否正确并包含在 PATH
环境变量中。我应该检查哪些其他依赖项?我目前正在使用 Microsoft VB 2010 Express 作为我的 IDE。
ant
其实是批处理脚本,不是可执行文件。这就是错误消息为 "The system cannot find the file specified" 的原因。 Windows 找不到名为 ant
.
的可执行文件
您可以将 cmd.exe
及其 /c
选项用于 运行 批处理脚本:
If (Not ExecuteProgram("cmd.exe", "/c ant word2html", True)) Then
我正在尝试通过 VB 项目使用 Apache Ant 运行 Python 应用程序 word2html
。以下代码调用了可执行文件。
//in loop
If (Not ExecuteProgram("ant", "word2html", True)) Then
Throw New System.Exception("couldn't run word2html")
End If
//executeprogram function
Public Function ExecuteProgram(ByVal ExeLoc As String, ByVal ExeArgs As String, ByVal bSynch As Boolean) As Boolean
'The exefile location is passed in along with a boolean value of whether to
'execute the file syncronously or asynchronously
Try
Dim MyInstance As New System.Diagnostics.Process
Dim si As New ProcessStartInfo(ExeLoc, ExeArgs)
MyInstance.StartInfo = si
MyInstance.Start()
If bSynch Then
'run synch
MyInstance.WaitForExit()
End If
Return True
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
End Function
几周前代码 运行 成功,但现在失败了 error message:
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at ConsoleApplication1.Hello.ExecuteProgram(String ExeLoc, String ExeArgs, Boolean bSynch)
in C:\Users\shwang\Desktop\svn\trunk\data\data_loading\scripts\data_sheet _scripts\Pipeline\ProcessDatasheetPipeline\Module1.vb:line 349
当我从 cmd
window 运行 ant word2html
时,它 运行 成功了。
我怀疑是我的工作环境发生了变化 我已经检查了 ANT_HOME
和 JAVA_HOME
变量是否正确并包含在 PATH
环境变量中。我应该检查哪些其他依赖项?我目前正在使用 Microsoft VB 2010 Express 作为我的 IDE。
ant
其实是批处理脚本,不是可执行文件。这就是错误消息为 "The system cannot find the file specified" 的原因。 Windows 找不到名为 ant
.
您可以将 cmd.exe
及其 /c
选项用于 运行 批处理脚本:
If (Not ExecuteProgram("cmd.exe", "/c ant word2html", True)) Then