【问题标题】:How to run a shell command without opening a CMD window in VB6如何在 VB6 中不打开 CMD 窗口运行 shell 命令
【发布时间】:2012-01-04 23:12:52
【问题描述】:

以下代码来自我的 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  

【问题讨论】:

  • 通过不明确告诉它显示:)

标签: windows vba vb6 batch-file


【解决方案1】:

您可以使用隐藏焦点:

Shell strCommand, vbHide

Shell strCommand, 0

对于其他焦点类型,请查看 Herehttp://msdn.microsoft.com/en-us/library/aa242087%28v=VS.60%29.aspx(感谢 MarkJ 提供链接)

【讨论】:

猜你喜欢
  • 2013-08-09
  • 1970-01-01
  • 1970-01-01
  • 2011-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-22
相关资源
最近更新 更多