2016-07-10 8 views
0

私は何の結果も得ずに多くを検索しましたので、私はあなたにアシックスしています! 私は、複数のWindowsシェルを開き、別のコンピュータに同じcommadを送信するために別のtelnet接続をロードします。私はそれが同時に行われる必要があります。だから、私は間違って別の "WScript.Shell"オブジェクトを作成し、それらにキーを送信使用してみてください。何も結果なし。どうやってやるの?マルチプルtelnet接続のための複数のシェルウィンドウでのコマンド

Option Explicit 
Dim tll1, tll2, tll3 
set tll1=CreateObject("WScript.Shell") 
set tll2=CreateObject("WScript.Shell") 
set tll3=CreateObject("WScript.Shell") 

tll1.run "cmd.exe" 
tll2.run "cmd.exe" 
tll3.run "cmd.exe" 
WScript.Sleep 1000 

tll1.SendKeys "telnet 192.168.114.254" 
tll1.SendKeys ("{Enter}") 
tll2.SendKeys "telnet 192.168.114.254" 
tll2.SendKeys ("{Enter}") 
tll3.SendKeys "telnet 192.168.114.254" 
tll3.SendKeys ("{Enter}") 
... 

最後のシェルウィンドウに入力されたwoleコマンドです。ありがとう!

+0

私は単一のマシンfotの初期テストを使用しているので、IPアドレスは同じです。 –

+0

"Wscript.Shell"を1つ作成するだけです。 AppActivateを使用します。 WScript.Shellのヘルプを参照してください。 –

+0

PS Windowsの場合は、別のウィンドウタイトルを持つように、Telnetダイレクト(cmdとtelnetを起動するのではなく)を使用し、各ウィンドウごとに異なるIPアドレスを設定する必要があります。 –

答えて

0

ありがとうございます。私はそれをやった!思い出させるべき唯一の事は、AppActivateとコマンドの間に眠ることです。私のためにはうまくいかない、ここでは最終的なコード

Option Explicit 

Dim wshShell 
set wshShell=CreateObject("WScript.Shell") 
wshShell.run "telnet.exe" 
WScript.Sleep 1000 
wshShell.SendKeys "o 192.168.114.251" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "admin" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "CMD_PC1" 

wshShell.run "telnet.exe" 
WScript.Sleep 1000 
wshShell.SendKeys "o 192.168.114.252" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "admin" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "CMD_PC2" 

wshShell.run "telnet.exe" 
WScript.Sleep 1000 
wshShell.SendKeys "o 192.168.114.254" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "userPC3" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "PWD_PC3" 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
wshShell.SendKeys "CMD_PC3" 
WScript.Sleep 1000 

wshShell.AppActivate "Telnet 192.168.114.251" 
WScript.Sleep 3 
wshShell.SendKeys ("{Enter}") 
wshShell.AppActivate "Telnet 192.168.114.252" 
WScript.Sleep 3 
wshShell.SendKeys ("{Enter}") 
wshShell.AppActivate "Telnet 192.168.114.254" 
WScript.Sleep 3 
wshShell.SendKeys ("{Enter}") 
WScript.Sleep 1000 
Wscript.Quit 
関連する問題