I'm attempting to log into a remote computer (Computer B) from (Computer A) using Remote Desktop. Once in, I want to pass values from Computer A to a command line on Computer B. I've managed to obtain the code to login successfully to Computer B, but when I attempt to try and call a Shell("cmd.exe") the program opens on Computer A rather than Computer B. I'm guessing its because my RDP session no longer has focus. Is there a simple way to handle this? I've been investigating WMI but I'm a little unsure how that all works. Would appreciate some guidance. Thanks!
Code
Sub Remote_Client_Server()
RDPWindow = Shell("C:\windows\system32\mstsc.exe /v:[Computer B]", 1)
With RDPWindow
Application.Wait (Now() + TimeValue("0:00:5"))
Application.SendKeys ("[Password for Computer B]")
Application.SendKeys ("{TAB}")
Application.SendKeys ("{TAB}")
Application.SendKeys ("{TAB}")
Application.SendKeys ("~")
Call Shell("cmd.exe", vbNormalFocus)
End With
End Sub
Display More