Solved

Print to the output stream

Posted on 2001-06-11
2
122 Views
Last Modified: 2010-05-02
I am developing a small, non-visual VB application which needs to send different messages to the DOS prompt.
I could not find a VB function which does it (something like 'printf' in C).
Also, if there is no such function in VB, does anyone know an API function instead of ?

Regards
0
Comment
Question by:marper
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
jrspano earned 113 total points
ID: 6177303
from planet source code

'**************************************
' Name: Send Keys/commands to DOS (the e
'     asy method)
' Description:Sending keystrokes to dos
'     is not as easy as the "Sendkeys" functio
'     n, which is designed specifically for wi
'     ndows based programs. So this program is
'     designed to add on to that function and
'     send keystrokes to dos. The program can
'     actually send any size text to the comma
'     nd prompt, from one keystroke to complet
'     e commands. It allows the programmer to
'     completely control dos applications.
' By: Philip Leitch
'
' Inputs:you will need to start a dos se
'     ssion, either before or during your appl
'     ication. If you are starting a dos sessi
'     on during the session you sould use the
'     following code:
x = shell("command", 0)
this will create a dos session, With windows handle of "x", which will be hidden from the program user.
Once created To End the session the standard "exit" can be sent to the command line.
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/xq/ASP/txtCode
'     Id.3593/lngWId.1/qx/vb/scripts/ShowCode.
'     htm'for details.'**************************************



Public Sub Dos_Send(CommandWindowName as string, SendToDos as string)
    clipboard.Clear
    'clear the clipboard (obvious)
    Clipboard.SetText SendToDos ' + Chr$(13)
    'send the relevent key/command to the cl
    '     ipboard
    'note that the Chr$(13) is requried to i
    '     f the "SendToDos" text is a dos command
    '     or 'requires the pressing of the Enter/R
    '     eturn key after the relevent string has
    '     been 'sent.
    AppActivate CommandWindowName
    'CommandWindowName is MS-DOS Prompt, or
    '     whatever appears in your task bar.
    'See the AppActivate for more info.
    'A good alternative is to use the handle
    '     (hwind) of the dos window
    SendKeys "% ep", 1
    'this sends the clipboard to dos
    'Now wasn't that simple?
End Sub
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6177339
here is a sample also that does more on the console

http://www.freevbcode.com/ShowCode.Asp?ID=1265
0

Featured Post

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.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now