Solved

Is it possible?

Posted on 2000-04-12
7
111 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

688 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