Results 1 to 3 of 3

Thread: close shell window not working help please

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599

    close shell window not working help please

    guys,


    how can i close the command prompt .......

    say i : shell "ping 192..168.100.111"
    then a command prompt appear and after a few seconds then i would like to close that command prompt .... how to?, Master\


    EXAMPLE :
    Dim phandle1 As Long

    If (Trim(txtipi1.Text) <> "") Then
    phandle1 = Shell("ping -t " & txtipi1.Text, vbMinimizedNoFocus)
    wapintstorage.setwapip1handle = phandle1
    End If


    later i issue this :

    SendMessage wapintstorage.getwapip1handle, WM_CLOSE, 0&, 0&


    It AINT WORKING
    Last edited by vbnew; Aug 14th, 2003 at 11:52 PM.
    Thank You

  2. #2
    Hyperactive Member Knowledge_is_Et's Avatar
    Join Date
    Dec 2001
    Location
    An Oak.
    Posts
    305
    you could try running a bat file, then just use the "exit" command
    or, since I don't know shell very well, the command to exit the command prompt is "exit"... yeap... good luck.
    Now returning to the world of VB. Please make sure your seatbelts are securely fastened and all trays are in their upright and locked position.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599

    Hmm.... i think this might help ..... i found somewhere here

    'These are the API declarations
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function TerminateProcess& Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long)
    Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Const PROCESS_TERMINATE = &H1
    Private Const PROCESS_QUERY_INFORMATION = &H400
    Private Const STILL_ACTIVE = &H103

    'Stick this in general declarations so the code
    'in your cancel button can also see it
    Dim ProcID As Long


    'This can go in your cancel button
    Dim hProc As Long
    hProc = OpenProcess(PROCESS_TERMINATE, 0, ProcID)
    TerminateProcess hProc, 0
    CloseHandle hProc


    'The rest of this can be used to start your c++ app
    Dim hProc As Long
    Dim ProcStatus As Long

    'Substitute notepad for your c++ app
    ProcID = Shell("notepad.exe", vbNormalFocus)
    'Get a handle to the process
    hProc = OpenProcess(PROCESS_QUERY_INFORMATION, 0, ProcID)
    Do
    'Allow other things to happen in your app, such as Cancel being pressed
    DoEvents
    'Get the status of the other app
    GetExitCodeProcess hProc, ProcStatus
    Loop While ProcStatus = STILL_ACTIVE
    'Close the handle, we're done with it
    CloseHandle hProc

    'Put any code here that is supposed to execute when the other app stops running
    MsgBox "It's done."
    Thank You

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