Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Executing a program from the Shell
Message
De
27/12/2005 13:24:56
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01080875
Message ID:
01081042
Vues:
11
>You can use the Process class and capture the redirection output into the StandardOutput stream.

Thanks, this is exactly what I needed:
Public Class ProcessFile

    Public cFileName As String = ""
    Public cWorkingDirectory As String = ""
    Public cArguments As String = ""
    Public oProcess As Process = New Process
    Public cResponse As String = ""

    Public Function Process() As String

        ' If we have a working directory
        If cWorkingDirectory.Length > 0 Then
            If Framework.FileFunction.DirectoryExist(cWorkingDirectory) = False Then
                App.cError = "The directory " + cWorkingDirectory + " does not exist."
                Return False
            End If
        End If

        If Framework.FileFunction.FileExist(cFileName) = False Then
            App.cError = "The file " + cFileName + " cannot be empty."
            Return False
        End If

        oProcess.StartInfo.FileName = cFileName
        oProcess.StartInfo.WorkingDirectory = cWorkingDirectory
        oProcess.StartInfo.Arguments = cArguments
        oProcess.StartInfo.RedirectStandardOutput = True
        oProcess.StartInfo.RedirectStandardInput = True
        oProcess.StartInfo.UseShellExecute = False
        oProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
        oProcess.StartInfo.CreateNoWindow = True

        Try
            oProcess.Start()
        Catch ex As Exception
            App.cError = ex.Message
            Return False
        End Try

        cResponse = oProcess.StandardOutput.ReadToEnd()

        Return True
    End Function

End Class
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform