Results 1 to 3 of 3

Thread: executing a dos program within vb

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Lincoln, NE
    Posts
    1
    I need help with the code to execute a dos program. The only code I can find for shell commands is Shell "c:\*\program.exe" (with the optional window format). This format gives me all sorts of errors. If you know how to do this, please help me out. Thanks!

  2. #2
    Guest
    This will launch a dos window.

    Code:
    Shell "C:\Dosprogram.exe", VbNormalFocus
    You can also shell a program and use its paremeters.

    Code:
    Shell ("command.com /c dir /b c:\ > c:\cListing.txt"), vbHide

    [Edited by Matthew Gates on 08-02-2000 at 11:17 PM]

  3. #3
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    This works much better you can even send it anything you can type at the run prompt including web pages. Someone asked the other day about it because the standard shell was crashing their win98 computer. This solved their problem


    Option Explicit

    Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal HwndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_SHOWWINDOW = &H40
    Private Const SWP_NOACTIVATE = &H10

    Public Enum WindowPos
    vbtopmost = -1&
    vbNotTopMost = -2&
    End Enum

    Public Sub SetFormPosition(hWnd As Long, Position As WindowPos)
    Const wFlags As Long = SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW Or SWP_NOACTIVATE
    If Position = vbtopmost Or Position = vbNotTopMost Then
    SetWindowPos hWnd, Position, 0, 0, 0, 0, wFlags
    End If
    End Sub

    ' call the procedure as follows
    '
    ' call alwaysontop.normal(me.hwnd)
    ' or
    ' OnTop (Me.hWnd)

    Public Sub OnTop(hWnd As Long)
    SetFormPosition hWnd, vbtopmost
    End Sub

    Public Sub Normal(hWnd As Long)
    SetFormPosition hWnd, vbNotTopMost
    End Sub
    Kurt Simons
    [I know I'm a hack but my clients don't!]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width