Solved

Is it possible?

Posted on 2000-04-12
7
106 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now