Solved

Is it possible?

Posted on 2000-04-12
7
108 Views
Last Modified: 2010-05-02
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!
0
Comment
Question by:mikef17
7 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 2706901
Use SendKeys

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

End Sub
0
 

Author Comment

by:mikef17
ID: 2707416
Hi,TimCottee!
Thanks for response.

This code not work properly.
Sendkeys function not works.
What possible problem???
0
 
LVL 1

Expert Comment

by:freg
ID: 2708022
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.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 9

Accepted Solution

by:
samopal earned 50 total points
ID: 2708114
SendKey doesn't work with console application. Here is a solution:

Create file yes.txt with 3 bytes only. First byte is "Y", 2 last bytes- (0D 0A)hex

In VB programm

Shell "C:\..\Prog.exe <C:\..\yes.txt"

HTH
0
 

Author Comment

by:mikef17
ID: 2710742
Hi,samopal!
What exactly i need type in text file
(i can't enter bytes?!)
0
 
LVL 9

Expert Comment

by:samopal
ID: 2712135
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! :-))
0
 

Author Comment

by:mikef17
ID: 2725270
Hi,samopal!
That's not work.May be self extracting file need some waiting time?
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question