nazirm Posted October 6, 2013 Posted October 6, 2013 Hi: I was trying to understand StdinWrite and have written the following two pieces of code. The first without StninWrite works well, but the second does not. Why? Nazir #include <Constants.au3> $pid = Run("C:\Windows\system32\cmd.exe","C:\", $STDIN_CHILD + $STDOUT_CHILD) WinWaitActive("C:\Windows\system32\cmd.exe") send("cd ") send("C:\users\test1") send("{enter}") Sleep(10000) Exit #include <Constants.au3> $pid = Run("C:\Windows\system32\cmd.exe","C:\", $STDIN_CHILD + $STDOUT_CHILD) WinWaitActive("C:\Windows\system32\cmd.exe") StdinWrite($pid,"cd") StdinWrite($pid,"C:\users\test1") StdinWrite($pid,@CRLF) Sleep(10000) Exit What am I doing wrong? Regards, Nazir
rodent1 Posted October 7, 2013 Posted October 7, 2013 2 comments: 1- you forgot a space after "cd" in the problem code 2- stdinwrite returns the number of characters written, or sets @error. If you replace your "cd" line with this Local $charnum = StdinWrite($pid,"cd ") then have a msgbox to look at the value of $charnum, you will see that the code never reaches the msgbox statement. According to help on stdinwrite, this means that "there is no room for more characters to be written to the stream". In other words, cmd.exe does not accept the input string, unless someone has a better interpretation of this problem.
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