[VB]Ejecutar .exe Con button y que se oculte

Iniciado por agustin_v8, 27 Diciembre 2009, 20:02 PM

0 Miembros y 2 Visitantes están viendo este tema.

fary

intenta con:

private sub command1_click()
call hola
end sub
private sub hola()
Call Shell("C:\Documents and Settings\USER\Escritorio\host\server1\samp-server.exe", vbHide)
end sub



espero que aora sique funcione... xD

salu2!
Un byte a la izquierda.

raul338

Cita de: agustin_v8 en 28 Diciembre 2009, 20:24 PM
Hola intente con

Código (vb) [Seleccionar]
Private Sub Command2_Click()
Call Shell("C:\Documents and Settings\USER\Escritorio\host\server1\samp-server.exe", vbHide)
End Sub


y compila perfecto, solo que al hacer clic no pasa nada :S, ni siquiera se ve que lo ejecuta y la ruta esta perfecta y VB toma la ruta bien.

Pero recordemos que el exe que intento ejecutar carga archivos tambien, como dije en comentarios anteriores, la cual puede ser que traiga inconvenientes.

Se supone que no se tiene que ver que se ejecuta no? (Para ver si se inicio el proceso, fijate en el administrador de tareas o alguno parecido).

El funcionamiento del exe no tiene nada que ver con que lo llames, y ... estas seguro de que la ruta que le pasas es la correcta? no necesitara algun parametro o algo?

Meta

Busca en VB .net el componente NotifyIcon.
Tutoriales Electrónica y PIC: http://electronica-pic.blogspot.com/

raul338

Cita de: Meta en 28 Diciembre 2009, 22:04 PM
Busca en VB .net el componente NotifyIcon.
:huh: :huh:


para que? Existe la manera (mediante API) de implementar NotifyIcon en vb6, pero no es lo que el esta "planteando" aca, el lo que quiere haces iniciar un proceso, pero que no se vea ninguna ventana de este, o si?

Y otra pregunta, el proceso es interactivo? (hace falta hacer click en un boton para que empieze a funcionar??)

xkiz ™

Código (vb) [Seleccionar]
Private Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
Private Sub Command2_Click()
    WinExec "C:\Documents and Settings\USER\Escritorio\host\server1\samp-server.exe", 0
End Sub

MCKSys Argentina

WinExec
The WinExec function runs the specified application.

This function is provided for compatibility with 16-bit Windows. Win32-based applications should use the CreateProcess function.

UINT WinExec(
  LPCSTR lpCmdLine,  // address of command line
  UINT uCmdShow      // window style for new application
);

Ojo al piojo, que la función está sólo por Compatibilidad...

MCKSys Argentina

"Si piensas que algo está bien sólo porque todo el mundo lo cree, no estás pensando."


BlackZeroX


Fuentes:

http://allapi.mentalis.org/apilist/CreateProcess.shtml
http://allapi.mentalis.org/apilist/3805D9F5937ACD5D7759F3FF7EEFFAAE.html

Código (vb) [Seleccionar]


'This program needs a common dialog box, named CDBox
' (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
' and select Microsoft Common Dialog control)
Const INFINITE = &HFFFF
Const STARTF_USESHOWWINDOW = &H1
Private Enum enSW
    SW_HIDE = 0
    SW_NORMAL = 1
    SW_MAXIMIZE = 3
    SW_MINIMIZE = 6
End Enum
Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessId As Long
    dwThreadId As Long
End Type
Private Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Byte
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type
Private Type SECURITY_ATTRIBUTES
    nLength As Long
    lpSecurityDescriptor As Long
    bInheritHandle As Long
End Type
Private Enum enPriority_Class
    NORMAL_PRIORITY_CLASS = &H20
    IDLE_PRIORITY_CLASS = &H40
    HIGH_PRIORITY_CLASS = &H80
End Enum
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Function SuperShell(ByVal App As String, ByVal WorkDir As String, dwMilliseconds As Long, ByVal start_size As enSW, ByVal Priority_Class As enPriority_Class) As Boolean
    Dim pclass As Long
    Dim sinfo As STARTUPINFO
    Dim pinfo As PROCESS_INFORMATION
    'Not used, but needed
    Dim sec1 As SECURITY_ATTRIBUTES
    Dim sec2 As SECURITY_ATTRIBUTES
    'Set the structure size
    sec1.nLength = Len(sec1)
    sec2.nLength = Len(sec2)
    sinfo.cb = Len(sinfo)
    'Set the flags
    sinfo.dwFlags = STARTF_USESHOWWINDOW
    'Set the window's startup position
    sinfo.wShowWindow = start_size
    'Set the priority class
    pclass = Priority_Class
    'Start the program
    If CreateProcess(vbNullString, App, sec1, sec2, False, pclass, _
    0&, WorkDir, sinfo, pinfo) Then
        'Wait
        WaitForSingleObject pinfo.hProcess, dwMilliseconds
        SuperShell = True
    Else
        SuperShell = False
    End If
End Function
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    'Set the dialog's title
    CDBox.DialogTitle = "Choose an EXEC-File ..."
    'Error when canceled
    CDBox.CancelError = True
    'Set the dialog's filter
    CDBox.Filter = "EXEC-Files (*.exe)|*.exe|All files (*.*)|*.*"
    'Show the 'Open File'-dialog
    CDBox.ShowOpen
    'Execute the program
    SuperShell CDBox.filename, Left$(CDBox.filename, Len(CDBox.filename) - Len(CDBox.FileTitle)), 0, SW_NORMAL, HIGH_PRIORITY_CLASS
    End
End Sub



Dulces Lunas!¡.
The Dark Shadow is my passion.