how to active (and set cursor into the box) a MSDOS box/prompt/ shell  in VB6 instead  of using  taskbar start/cmd

BIAPRO
BIAPRO used Ask the Experts™
on
I need  a cmdbutton for user to click on  and goto dosprompt, instead off explaining him to use taskbar and type cmd , enter
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Analyst programmer
Commented:


Get the location of the dos prompt. It should be in the windows system directory, which you could either hard code or use the "GetSystemDirectoryA" API:

Private Declare Function GetSystemDirectory Lib "kernel32" _
    Alias "GetSystemDirectoryA" ( _
    ByVal lpBuffer As String, _
    ByVal nSize As Long) _
As Long

So to find the location using the API:

Dim s       As String    
Dim Result  As Long

    s = String(261, 0)
    Result = GetSystemDirectory(s, 261)
    If Result Then
        s = Left(s, Result)
      If Right(s, Len("\")) <> "\" Then
            s = s & "\"
       End If
       s = s & "cmd.exe"
    Else
      ' Could not find system directory...
    End If

And then somehow start it. The easiest way would be:

Shell s, vbNormalFocus

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial