Skip to content

Scheduling and passing arguments from EXE file

Lakshmi T

Asked Oct 18, 2012, 2:18 AM EDT1 answer
Share
LinkedInX
Hi


I am using a window service for job processing. This window service in turn calls other exe for Processing. How can i pass arguments between one window service and exe file.

And also i need to implement scheduled service in windows service. How can i implement scheduling and passing arg to exe file in window service?

Thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi Laksmi,

    Please try below code in the windows service to pass argument to the EXE through Windows service.

    If you want to schedule Windows service then try for Winodws Scheduler (It comes with OS) instead of Windows service.


    CODE
    =========================

    Dim myProcess As Process = Nothing

    Try


    myProcess = Process.Start("EXE path", "pass arguments here")
    myProcess.WaitForExit()

    Catch ex As Exception
                If Not myProcess Is Nothing Then
                    myProcess.Close()
                End If

    Finally
                If Not myProcess Is Nothing Then
                    myProcess.Close()
                End If

                Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Name of EXE")
                If Not pProcess Is Nothing Then
                    If pProcess.Length > 0 Then
                        For Each p As Process In pProcess
                            p.Kill()
                        Next
                    End If
                End If

    End Try
    0