以下代码来 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
对于其他焦点类型,请查看 Here 或 http://msdn.microsoft.com/en-us/library/aa242087%28v=VS.60%29.aspx (感谢 MarkJ 提供的链接)
关于windows - 如何在不打开 VB6 中的 CMD 窗口的情况下运行 shell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8735463/