Chance1 Posted July 25, 2017 Share Posted July 25, 2017 Hello, I am trying to send some commands to a powershell window using the ControlSend function. I get the handle of the powershell window and send the command, the command consists of upper and lower case letters within words, as well as '-' and variables. The ControlSend will also change the variables that are being send to the powershell (by change the variables I mean it changes the letters from upper to lower as well as changing say a zero '0' to ')' ). There is no pattern as sometimes the command is sent properly, but more times than not, the command has something wrong. Has anyone experienced this before? Know of a way to fix this? Thanks! Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25, 2017 Developers Share Posted July 25, 2017 Maybe: https://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F Jos SkysLastChance 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chance1 Posted July 25, 2017 Author Share Posted July 25, 2017 @Jos that may help a little bit. but, the problem is that there is a mixture in the controlsend. Here is what I am trying to send to the powershell. ControlSend($hWnd, '', '', 'Enter-PSSession -ComputerName ' & $Domain & ' -Credential ' & $TargetUsername ) (So that is a powershell command being sent to the powershell window with Autoit). So that link may be helpful, but it might be too tedious to have to force the shift, ALT, or Crtl key to do down or not. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25, 2017 Developers Share Posted July 25, 2017 I don't know what else you do on the computer to make one of those keys stick, but let me ask you why are you interacting with powershell via the front in stead of the STDIO method? When you shell powershell from the script, you should be able to send commands that way and not be bothered by other influences. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chance1 Posted July 25, 2017 Author Share Posted July 25, 2017 You are right, I will give it a shot Link to comment Share on other sites More sharing options...
Chance1 Posted July 25, 2017 Author Share Posted July 25, 2017 @Jos this is an unrealted question to the topic but to what you suggested. When I run the powershell and try to use STDIO, I cannot see the powershell commands being send so I am not sure how to test this code. When I use @SW_SHOW or @SW_MAXIMIZE i just get a blank powershell window running. So I do not know if the commands are working or not. Link to comment Share on other sites More sharing options...
Chance1 Posted July 25, 2017 Author Share Posted July 25, 2017 Also, By the end of the script executing, I want the user to be able to interact with the powershell window. The point of the script is to sign in the user onto a Domain. So I am not sure if using Run this way will allow for this. Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25, 2017 Developers Share Posted July 25, 2017 You are correct that when using STDIO, the user won't see the information anymore. in the powershell window. Sorry about that Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Chance1 Posted July 25, 2017 Author Share Posted July 25, 2017 After closing StdinWrite, will the user be able to interact with powershell window then or no? Link to comment Share on other sites More sharing options...
Developers Jos Posted July 25, 2017 Developers Share Posted July 25, 2017 The process will end when the STDIO is closed by the script end. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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