Reputation: 140
I'm automating process of connection to remote PC which includes VPN+SSH+VNC and ssh stage automatization opens too much new windows instead of one expected.
Code:
Set oShell = CreateObject("WScript.Shell")
oShell.Run("""G:\Git\git-bash.exe""")
oShell.AppActivate "MINGW64:/"
Dim command
command = "ssh -A username@adress options~"
oShell.SendKeys command
Opens from 3 to 5 git-bash instances instead of 1. Sending keys works as intended in 1 of this 3-5 window. How to prevent opening others?
Upvotes: 0
Views: 133
Reputation: 1436
oShell.Run(oShell.ExpandEnvironmentStrings("%COMSPEC% /C (start G:\Git\git-bash.exe)"))
should help.
Might also try adding a WScript.Sleep 3000
before calling oShell.AppActivate
to give the OS time to launch git-bash.exe and its dependencies.
Hopefully, drive G: is a local drive. If not, increase the Sleep time to give any anti-virus time to scan the process.
Upvotes: 1