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

标签 windows vba vb6 batch-file

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

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

关于windows - 如何在不打开 VB6 中的 CMD 窗口的情况下运行 shell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8735463/

相关文章:

regex - 从命令输出中解析 WebSphere JVM 名称的 Windows 脚本

windows - 如何使用 xcopy 将文件复制到不存在的目录中?

excel - 如果单元格包含字符串 X,则删除整行

sql-server - 使用 ADO 时返回成功执行 SQL 的数据库消息

vb6 - 如何使用 VB6 和 MSXML 漂亮地打印 XML 源代码?

windows - Linux上.Net的潜在问题是什么

Windows批处理脚本从文件名中删除括号中的文本?

vba - 无法正确取消Application.Inputbox

excel - 在事件处理程序中触发 Enter 和 Exit 事件

c# - 如何从 C# 访问和理解旧的 dll