Link to home
Start Free TrialLog in
Avatar of mikef17
mikef17

asked on

Is it possible?

I want run self extracting file from VB.
That file will be run in DOS window.
And ask me enter Yes(Y) or No(N),and
Enter after that.How can i do it in VB
insted of user (i want that user will not press any key).

Thanks in advance!
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Use SendKeys

Private Sub Command2_Click()
Dim dblProcID As Double
dblProcID = Shell("SelfExtractingEXE.EXE")
AppActivate (dblProcID)
SendKeys "Y{ENTER}"

End Sub
Avatar of mikef17
mikef17

ASKER

Hi,TimCottee!
Thanks for response.

This code not work properly.
Sendkeys function not works.
What possible problem???
I think that the code from TimCottee is right, but the SendKey is probably sent too soon.  In fact, as soon as the dos shell is launched (with de self-extract file running), the vb code continue and then the 'Y' + 'ENTER' keys are sent, even before the question (Y / N ?) is asked.  Find a way to send the key later.

An other solution would be using ShellExecute and pass a parameter to the self-extractingExe (ex.: /Y).  Try it.
ASKER CERTIFIED SOLUTION
Avatar of samopal
samopal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mikef17

ASKER

Hi,samopal!
What exactly i need type in text file
(i can't enter bytes?!)
Ok. Open Notepad, press <Y> and <Enter>. Save this file as "Yes.txt" The length of this file should be 3 bytes, and no bit more! :-))
Avatar of mikef17

ASKER

Hi,samopal!
That's not work.May be self extracting file need some waiting time?