简体   繁体   English

在VB.net中执行EXE

[英]Executing an EXE in VB.net

I'm trying to execute a exe file in vb.net but i'm not getting any luck doing it. 我正在尝试在vb.net中执行一个exe文件,但是这样做没有任何运气。

I've found multiple examples on the internet doing it but it is not working for me. 我在互联网上发现了多个示例,但它对我不起作用。

    Dim file As String = "C:\Inetpub\wwwroot\TEST\TestConsoleApp.exe"

    Dim str As SecureString = ConvertToSecureString("PASSWORD")

    Dim info As ProcessStartInfo = New ProcessStartInfo(file, new_num)
    info.UserName = "USERNAME"
    info.Password = str
    info.UseShellExecute = False
    info.CreateNoWindow = True

    Dim p As Process = Process.Start(info)

Function ConvertToSecureString(ByVal str As String)
    Dim password As New SecureString
    For Each c As Char In str.ToCharArray
        password.AppendChar(c)
    Next
    Return password
End Function

When i run the exe manually or locally through vs 2010, it works fine for me, but when I put on on the server a response at all. 当我手动运行该exe或在vs 2010中本地运行该exe时,它对我来说很好用,但是当我在服务器上放一个响应时,根本没有响应。 What I mean by response is when the exe is complete I write to a text file that exe has been completed. 我的反应是当exe完成时,我将文本写入exe已完成的文件中。

Thanks in advance 提前致谢

Have you tried HttpContext.Current.Server.MapPath(TestConsoleApp.exe) instead of the hardcoded C:\\Inetpub\\wwwroot\\TEST\\TestConsoleApp.exe ? 您是否尝试过HttpContext.Current.Server.MapPath(TestConsoleApp.exe)而不是硬编码的C:\\Inetpub\\wwwroot\\TEST\\TestConsoleApp.exe I am assuming TEST is the name of your virtual directory, right? 我假设TEST是您的虚拟目录的名称,对吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM