2012-01-04 33 views
11

el siguiente código es parte de mi programa de Visual Basic 6Cómo ejecutar un comando shell sin abrir una ventana de CMD en VB6

Solía ​​comando shell en el VB con el fin de ejecutar el pscp.exe con las banderas y argumentos

mi problema es, cuando se ejecuta la línea VB:

 Shell strCommand, 1 

su también abrir la ventana de CMD durante 2-4 segundos (ventana emergente CMD)

mi pregunta - ¿es posible t o ejecuta el "Shell strCommand, 1" en la forma en que la ventana de CMD no se abrirá?

quiero decir - no quiero ver ninguna ventana emergente CMD cuando corro uso de VB

Const cstrSftp As String = "D:\pscp.exe" 
    Dim strCommand As String 
    Dim pUser As String 
    Dim pPass As String 
    Dim pHost As String 
    Dim pFile As String 
    Dim pRemotePath As String 
    pUser = "root" 
    pPass = "pass123" 
    pHost = "110.218.201.15" 
    pFile = """D:\scan_ip.ksh""" 
    pRemotePath = "/var/tmp" 

    strCommand = cstrSftp & " -sftp -l " & pUser & " -pw " & pPass & " " & pHost & ":" & pRemotePath & " " & pFile 


    Shell strCommand, 1 
+0

Al no decir explícitamente que se muestre :) – Deanna

Respuesta

20

Puede utilizar el enfoque oculta:

Shell strCommand, vbHide 

o

Shell strCommand, 0 

Para otros tipos de enfoque se ven Here o http://msdn.microsoft.com/en-us/library/aa242087%28v=VS.60%29.aspx (gracias a Mar kJ para el enlace)

+1

Excelente respuesta thx –

+2

+1 Los argumentos también están documentados en el manual http://msdn.microsoft.com/en-us/library/aa242087 (v = VS.60) .aspx – MarkJ

Cuestiones relacionadas