Results 1 to 19 of 19

Thread: External .exe file input

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    External .exe file input

    Dear all,

    I am quite new to programming so please bear with me if I am asking stupid questions.
    I have searched the forums but couldn't find a (comprehensible) answer.

    I am calling an external .exe file from VB, I do this with Shell.
    The external .exe opens a command window and asks for a file name. I am trying to make vb to input a file name into the command window but I m not sure how. The SendKeys command doesn't seem to work.
    Could somebody please help me out?
    Thanks!!

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: External .exe file input

    Oh boy, you will need to delve in to the API... Are you sure it is a command window and not a common dialog? And if it is a command window, ie a dos box, then does not the program accept command line parameters and if it does, would not passing it the path/file name of the file to be processed be better than trying to hook a cmd window? Then if you must hook into this window, you will have to delve into the API... FindWindow and SendMessage come to mind... Perhaps a better definition and/or a screen shot so we know exactly what you are trying to accomplish might be in order.



    Good Luck
    Option Explicit should not be an Option!

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    Hmm, how can I tell if its a common dialog? And if it is, what can I do?

    It is not a dos window, it doesnt have the C:\> and flashing cursor and you certainly can't type dos commands on it, it just asks for a file name.
    I'll certainly try the Findwindow and Sendmessage, thanks for the suggestion!

  4. #4
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: External .exe file input

    Lets see a screenshot of the dialog... A common dialog is displayed with most any program when you go to saveas, open, select a font, or select colors. This same dialog you would see in word, excel, acrobat, and so on...



    Good Luck
    Option Explicit should not be an Option!

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    Oh, in that case its not a common dialog box, its a command box (dos box). How can I pass it the path/filename? I have tried inputing it to Shell e.g.

    Shell("D:\test\cif.exe" & filename, AppWinStyle.MaximizedFocus)
    but I get a file not found error!

    Thank you very much for your help!

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    And here is a screenshot
    Last edited by banban; Jul 2nd, 2010 at 08:51 AM.

  7. #7
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: External .exe file input

    You might wanna try that with a space in between there
    Code:
    Shell("D:\test\cif.exe " & filename, AppWinStyle.MaximizedFocus)
    Also, are you sure you're not using .NET?
    I don't recognize that AppWinStyle
    Last edited by TheBigB; Jun 29th, 2010 at 07:13 AM.
    Delete it. They just clutter threads anyway.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    I am using net... I'm in the wrong forum right? Sorry about that!
    It doesn't work with the space either... unfortunately!

  9. #9
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: External .exe file input

    No problem, I notified the moderators.
    If you want to send me the files, I sent you a private message with my email address.
    (forum policy doesn't allow you to post executables)
    Delete it. They just clutter threads anyway.

  10. #10

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    I dont think that sending an exe is necessary at this point. I suppose there must be a way to send information to a command box? Anyone??

  11. #11
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: External .exe file input

    Thread moved from 'VB6 and Earlier' forum to 'VB.Net' (VB2002 and later) forum

    (thanks for letting us know TheBigB )

  12. #12
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: External .exe file input

    Enter the commandline and navigate to D:\test
    Then try "cif.exe /?"
    Does it give you a list of parameters?
    Delete it. They just clutter threads anyway.

  13. #13
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: External .exe file input

    Have a look at this article that describes how to launch External Applications from VB.NET Application, send input to it and get output from it.
    http://pradeep1210.spaces.live.com/b...y?sa=694013424

    It is also in my signature.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  14. #14

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    When I try cif.exe /? it practically ignores the /? runs the cif.exe and asks for an input file as in the screenshot above.

  15. #15

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    Pradeep1210, in your code, where should I put my .exe file? If I understand this correctly, I should replace .FileName = "CMD.EXE" with .FileName = "CIF.EXE", right?

  16. #16
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: External .exe file input

    Try it. If it works then good.
    Otherwise, start CMD.EXE and first send CIF.EXE as input then the filename etc.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  17. #17

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    Hmmm, the problem is how to send the file name. You are proposing WriteLine(somevariable) right?
    Great code by the way!

  18. #18
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: External .exe file input

    yes, and that somevariable can be your exe (with full path).
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  19. #19

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    10

    Re: External .exe file input

    Could someone please help me write a code with Findwindow and Sendmessage? Everything else doesn't seem to work.
    Thanks!

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