Sphax479 Posted July 24 Share Posted July 24 Hi ! I've got the following script working on an unlocked windows station that works great : expandcollapse popup#autoit3wrapper_usex64=n ; runs the script in 32 bit program mode ; Use False to disable redirection, it will only apply to the program if running as 32 bit process _Wow64FsRedirection(False) Run("C:\Windows\System32\telnet.exe") _Wow64FsRedirection(True) ; http://www.autoitscript.com/forum/topic/111647-macro-problem-in-win7-x64/#entry790037 Func _Wow64FsRedirection($state) ; Disables or reverts the filesystem redirector for a 32 bit process running on 64bit OS If Not @AutoItX64 And @OSArch = 'X64' Then If $state Then DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 0) Else DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0); or 1 as per help EndIf If @error Then Return SetError(1) EndIf EndFunc WinWait("C:\Windows\system32\cmd.exe", "", 2) Send("open 172.16.34.13{ENTER}") sleep(1000) Send("login{ENTER}") sleep(1000) Send("password{ENTER}") sleep(20000) Send("mgr{ENTER}") sleep(5000) $n = 13 Send("{DOWN " & $n &"}") Send("{ENTER}") sleep(1000) $n2 = 1 Send("{DOWN " & $n2 &"}") Send("{ENTER}") $n3 = 3 Send("{DOWN " & $n3 &"}") Send("{BACKSPACE}") Send("20") Send("{F1}") $n4 = 17 Send("{DOWN " & $n4 &"}") $n5 = 4 Send("{BACKSPACE " & $n5 &"}") $n5 = 4 Send("{BACKSPACE " & $n5 &"}") Send("1010") $n6 = 3 Send("{DOWN " & $n6 &"}") $n7 = 4 Send("{BACKSPACE " & $n7 &"}") Send("1010") $n8 = 3 Send("{DOWN " & $n8 &"}") $n9 = 4 Send("{BACKSPACE " & $n9 &"}") Send("1010") $n10 = 3 Send("{DOWN " & $n10 &"}") $n11 = 4 Send("{BACKSPACE " & $n11 &"}") Send("1010") Send("{F1}") Send("{F1}") WinClose("Telnet 172.16.34.13") I'm trying to get this to work in a scheduled task while my session is locked. From what i understand Send() does not work on a locked station and has to be replaced by ControlSend() but i can't seem to make it work on my opened telnet window Has anyone faced this situation and could give a hand ? Link to comment Share on other sites More sharing options...
Nine Posted July 24 Share Posted July 24 Try thru stdio (see help file : StdinWrite) “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Sphax479 Posted July 24 Author Share Posted July 24 Tried using StdinWrite to no avail So went back to using ControlSend and looks like i got it working with this syntax : ControlSend ("C:\Windows\System32\telnet.exe","","","open 172.16.34.13{ENTER}") It works fine when i run the .au3 file, the compiled .exe has no problem either However, once compiled, added to scheduled task and ran while the session is disconnected, here is the output in the telnet window : open &èé;&-;"';&" I'm on a french keyboard layout and it looks like CAPSLOCK gets turned on : & = 1 è = 7 é = 2 I tried adding the flag " $SEND_RAW (1)" to the ControlSend, but nothing changes Any idea on what is happening ? Link to comment Share on other sites More sharing options...
Sphax479 Posted July 24 Author Share Posted July 24 Here's the full script by the way : expandcollapse popup#autoit3wrapper_usex64=n ; runs the script in 32 bit program mode ; Use False to disable redirection, it will only apply to the program if running as 32 bit process _Wow64FsRedirection(False) Run("C:\Windows\System32\telnet.exe") _Wow64FsRedirection(True) ; http://www.autoitscript.com/forum/topic/111647-macro-problem-in-win7-x64/#entry790037 Func _Wow64FsRedirection($state) ; Disables or reverts the filesystem redirector for a 32 bit process running on 64bit OS If Not @AutoItX64 And @OSArch = 'X64' Then If $state Then DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 0) Else DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0); or 1 as per help EndIf If @error Then Return SetError(1) EndIf EndFunc WinWait("C:\Windows\system32\cmd.exe", "", 2) ControlSend ("C:\Windows\System32\telnet.exe","","","open 172.16.34.13{ENTER}","$SEND_DEFAULT (0)") Sleep(1000) ControlSend ("Telnet 172.16.34.13","","","login{ENTER}") sleep(1000) ControlSend ("Telnet 172.16.34.13","","","password{ENTER}") sleep(20000) ControlSend ("Telnet 172.16.34.13","","","mgr{ENTER}") sleep(5000) $n = 13 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n &"}") ControlSend ("Telnet 172.16.34.13","","","{ENTER}") sleep(1000) $n2 = 1 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n2 &"}") ControlSend ("Telnet 172.16.34.13","","","{ENTER}") $n3 = 3 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n3 &"}") ControlSend ("Telnet 172.16.34.13","","","{BACKSPACE}") ControlSend ("Telnet 172.16.34.13","","","40") ControlSend ("Telnet 172.16.34.13","","","{F1}") $n4 = 17 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n4 &"}") $n5 = 4 ControlSend ("Telnet 172.16.34.13","","","{BACKSPACE " & $n5 &"}") $n5 = 4 ControlSend ("Telnet 172.16.34.13","","","{BACKSPACE " & $n5 &"}") ControlSend ("Telnet 172.16.34.13","","","1010") $n6 = 3 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n6 &"}") $n7 = 4 ControlSend ("Telnet 172.16.34.13","","","{BACKSPACE " & $n7 &"}") ControlSend ("Telnet 172.16.34.13","","","1010") $n8 = 3 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n8 &"}") $n9 = 4 ControlSend ("Telnet 172.16.34.13","","","{BACKSPACE " & $n9 &"}") ControlSend ("Telnet 172.16.34.13","","","1010") $n10 = 3 ControlSend ("Telnet 172.16.34.13","","","{DOWN " & $n10 &"}") $n11 = 4 ControlSend ("Telnet 172.16.34.13","","","{BACKSPACE " & $n11 &"}") ControlSend ("Telnet 172.16.34.13","","","1010") ControlSend ("Telnet 172.16.34.13","","","{F1}") ControlSend ("Telnet 172.16.34.13","","","{F1}") WinClose("Telnet 172.16.34.13") Link to comment Share on other sites More sharing options...
Nine Posted July 24 Share Posted July 24 Remove quotes and (0), just put $SEND_DEFAULT or $SEND_RAW. What is in parenthesis is the value of the constant ($SEND_DEFAULT or $SEND_RAW) ControlSend ("C:\Windows\System32\telnet.exe","","","open 172.16.34.13{ENTER}", $SEND_RAW) or ControlSend ("C:\Windows\System32\telnet.exe","","","open 172.16.34.13{ENTER}", 1) both are identical “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Sphax479 Posted July 24 Author Share Posted July 24 I used the second method : ControlSend ("C:\Windows\System32\telnet.exe","","","open 172.16.34.13{ENTER}", 1) When testing in the telnet window the output was : open 172.16.34.13{ENTER} So i modified to the following : ControlSend ("C:\Windows\System32\telnet.exe","","","open 172.16.34.13", 1) ControlSend ("C:\Windows\System32\telnet.exe","","","{ENTER}") But i still get the same output when ran in a scheduled task and logged off : Microsoft Telnet> open &èé;&-;"';&" Link to comment Share on other sites More sharing options...
Nine Posted July 24 Share Posted July 24 (edited) Tested on my computer. I have also a french OS and french Keyboard. Compiled x86 (32 bits) Made a one run task at specific time. Locked computer. Works as intended. #autoit3wrapper_usex64=n #include <WinAPIFiles.au3> Opt("WinTitleMatchMode", -2) _WinAPI_Wow64EnableWow64FsRedirection(False) Run("telnet.exe", "", @SW_SHOW) Local $hWnd = WinWait("telnet") ControlSend($hWnd, "", "", "open 172.16.34.13") Edited July 24 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Sphax479 Posted July 25 Author Share Posted July 25 (edited) Modified my script to add your solution and it looks like i still have the same behaviour through a scheduled task Now there is a subtlety about the locked session. It's not locked like when you press Win + L. It's a remote rdp session that I intentialy close this way : In the scheduled task here are the parameters i use : This is the only way i have seen the telnet session being really initiated. Maybe i'm doing something wrong ? Edited July 25 by Sphax479 Link to comment Share on other sites More sharing options...
Nine Posted July 25 Share Posted July 25 3 hours ago, Sphax479 said: It's a remote rdp session that I intentialy close this way That could be the difference, I don't know. As for the parameters of the task, I used the same. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
junkew Posted July 30 Share Posted July 30 See the remarks in the help of controlsend * Try an underscore after open instead of space * try 3 controlsends as separate commands Open,Ip,Enter sorry no solution just some more things to experiment. Under the hood of controlsend its probably sendmessage and postmessage win32 api. Maybe keybd_event or sendinput can help but no quarantee Get key state commands can help finding out if shift or capslock is on. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
rudi Posted August 1 Share Posted August 1 (edited) Hello, as @Nine already mentioned here try stdio See help file for Run() especially the opt_flag notes StdinWrite() StdoutRead() and I'd like to mention to use plink.exe rather than telnet plink help URL Edited August 1 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Zedna Posted August 20 Share Posted August 20 1) look at my old topic about Send/ControlSend cripled national characters problem 2) Try to search this forum for "telnet", there are some useful topics about directly calling telnet without Send/ControlSend ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now