|
-
Jun 28th, 2010, 05:40 AM
#1
Thread Starter
New Member
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!!
-
Jun 28th, 2010, 06:58 AM
#2
Frenzied Member
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!
-
Jun 28th, 2010, 07:11 AM
#3
Thread Starter
New Member
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!
-
Jun 29th, 2010, 12:54 AM
#4
Frenzied Member
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!
-
Jun 29th, 2010, 06:52 AM
#5
Thread Starter
New Member
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!
-
Jun 29th, 2010, 07:00 AM
#6
Thread Starter
New Member
Re: External .exe file input
Last edited by banban; Jul 2nd, 2010 at 08:51 AM.
-
Jun 29th, 2010, 07:10 AM
#7
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.
-
Jun 29th, 2010, 07:17 AM
#8
Thread Starter
New Member
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!
-
Jun 29th, 2010, 07:30 AM
#9
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.
-
Jun 29th, 2010, 07:35 AM
#10
Thread Starter
New Member
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??
-
Jun 29th, 2010, 07:40 AM
#11
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 )
-
Jun 29th, 2010, 07:48 AM
#12
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.
-
Jun 29th, 2010, 07:51 AM
#13
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.
-
Jun 29th, 2010, 07:52 AM
#14
Thread Starter
New Member
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.
-
Jun 29th, 2010, 08:02 AM
#15
Thread Starter
New Member
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?
-
Jun 29th, 2010, 08:07 AM
#16
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.
-
Jun 29th, 2010, 08:10 AM
#17
Thread Starter
New Member
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!
-
Jun 29th, 2010, 08:14 AM
#18
Re: External .exe file input
yes, and that somevariable can be your exe (with full path).
-
Jul 1st, 2010, 08:26 AM
#19
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|