Results 1 to 5 of 5

Thread: Send commands to Apps

  1. #1

    Thread Starter
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Send commands to Apps

    I want to make an App, for example will do a event like make the form transparent, but do so with command line parameters passed to it.


    How & where does one Define it. Like some command line programs take -x, -w parameters. How can I Make c:\bin\er.exe -con mean that the program if alreay running will then make the form transparent. This isnt about making the form transparent, just to give an Example of what I mean
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Send commands to Apps

    VB Code:
    1. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         'Allows program to be executed via command line, given a filename as an argument
    3.         Dim sArgs() As String = GetCommandLineArgs()
    4.         If Not sArgs(0) = Nothing Then
    5.             If File.Exists(sArgs(0)) Then
    6.                 Remove_Garbage(sArgs(0))
    7.             End If
    8.             Application.Exit()
    9.         End If
    10.     End Sub
    11.     Function GetCommandLineArgs() As String()
    12.         Dim separators As String = " "
    13.         Dim commands As String = Microsoft.VisualBasic.Command()
    14.         Dim args() As String = commands.Split(separators.ToCharArray)
    15.  
    16.         Return args
    17.     End Function

  3. #3

    Thread Starter
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Lightbulb Re: Send commands to Apps

    wild_bill,

    How does one define a specific argument. EG. -kill means application.exit, for example, where is that done.

    Could you please Include an Example.

    Thanks you.
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    Re: Send commands to Apps

    You just write code in your application to handle whatever data is in the Command Line arguments. The bigger problem you are going to have is that the application will only get these upon start up. So if you try to send commands to an application after it is running then it will spawn a new instance. You have to make a way to pass the command line from the new instance to the already running one.

    Try this it does pretty much exactly that:
    http://www.edneeis.com/example.aspx?ID=17

  5. #5

    Thread Starter
    Addicted Member Codehammer's Avatar
    Join Date
    Aug 2004
    Posts
    164

    Re: Send commands to Apps

    Busy checking this out Now

    http://www.edneeis.com/example.aspx?ID=17

    Thanks
    Curiosity SKILLED the cat
    Google Talk from your Mobile phone

    Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width