繁体   English   中英

如何在不打开VB6中的CMD窗口的情况下运行Shell命令

[英]How to run a shell command without opening a CMD window in VB6

以下代码是我的VB6程序的一部分

我在VB中使用了shell命令,以执行带有标志和参数的pscp.exe。

我的问题是,当VB运行该行时:

      Shell strCommand, 1  

它还会打开CMD窗口2-4秒(CMD弹出窗口)

我的问题-是否可以以不打开CMD窗口的方式运行“ Shell strCommand,1”?

我的意思是-我不希望在运行VB应用程序时看到任何CMD弹出窗口

  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  

您可以使用隐藏焦点:

Shell strCommand, vbHide

要么

Shell strCommand, 0

有关其他焦点类型,请参见此处http://msdn.microsoft.com/zh-cn/library/aa242087%28v=VS.60%29.aspx (感谢MarkJ提供的链接)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM