Gameday Posted May 17, 2011 Share Posted May 17, 2011 I am automating a remote command prompt, using Ruby and AutoIt. The AutoIt part looks like this:$title = $CmdLine[1] $command = $CmdLine[2] AutoItSetOption("WinTitleMatchMode", 4) $firstWindowHandle = WinGetHandle($title) If $firstWindowHandle Then WinActivate($firstWindowHandle) ControlSend("","",$firstWindowHandle,$command) WinSetState($title,"",@SW_MINIMIZE) Else MsgBox(0,"Error","Cannot find window") Exit EndIfI compiled the script into an exe, and I'm running it like this:finder "MyWindow" "dir"And this will execute dir in that prompt. Locally everything works ok. Remotely, I'm running into a bit of problems when running commands like:finder "MyWindow" "dir && ls"As I'm always getting back finder "MyWindow" "dir 77 ls"How can I make the && be interpreted as a & and not as a 7? I also tried sending the command like dir {ASC 38}{ASC 38} but AutoIt is always transforming it into a 7. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 17, 2011 Share Posted May 17, 2011 Try setting the flag to 1 (raw).Send - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Gameday Posted May 17, 2011 Author Share Posted May 17, 2011 (edited) Try setting the flag to 1 (raw).SendI tried it, and I still get two 7. Edited May 17, 2011 by Gameday Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 17, 2011 Share Posted May 17, 2011 (edited) <strike> My previous post is ridiculous. I think it has nothing to do with your question. My mind must've been somewhere else. Sorry 'bout that. </strike> Edited May 17, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Gameday Posted May 17, 2011 Author Share Posted May 17, 2011 (edited) One more strange thing I noticed. If I run this locally: $title = "MyWindow" $command = "dir && ls{ENTER}" AutoItSetOption("WinTitleMatchMode", 4) $firstWindowHandle = WinGetHandle($title) If $firstWindowHandle Then WinActivate($firstWindowHandle) ControlSend("","",$firstWindowHandle,$command) WinSetState($title,"",@SW_MINIMIZE) Else MsgBox(0,"Error","Cannot find window") Exit EndIf But if I run it on a remote computer, I always get 7's. Is there some option I should be setting AutoIt? Maybe one more clarification is in order. I have a Ruby client/server, which transports the commands over TCP. The commands are both sent/received correctly by Ruby, I tested. After the ruby client gets the data, it runs this: system("runner.exe \"#{win_title}\" \"#{command}\"") Basically, it interpolates the title and the command in a single string, which gets passed to the compiled autoit script. I have no idea what goes wrong. Printing the command line from AutoIt, shows it receives a &, but when it sends, the cmd.exe receives 7. Edited May 17, 2011 by Gameday 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