Jump to content

Unable to get console input mode - 0x80070006 The handle is invalid


fcjoe
 Share

Recommended Posts

Hello,

I'm trying to get the output from running a command. I copied the example from AutoIt's help file but I keep getting an error: Unable to get console input mode - 0x80070006 The handle is invalid

I'm trying to run the Bitsadmin.exe program. Bitsadmin

If I change the command line and remove the "/getstate test" I get the output without any errors. But if I add any options to the command line I get the same error. The error message comes from StdoutRead, StderrRead doesn't return anything.

My code is below.

Thanks,

Joe

#include <Constants.au3>

$foo = Run(@ComSpec & " /c C:\bitsadmin.exe /getstate test", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

While 1
    $line = StderrRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDERR read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")
Link to comment
Share on other sites

Sometimes certain command line utility give nothing in output.

I think bitsadmin is in this case...Posted Image

It does give output, it even has option flags to make the output easier to read for parsing (/RAWRETURN] [/WRAP | /NOWRAP)
Link to comment
Share on other sites

It does give output, it even has option flags to make the output easier to read for parsing (/RAWRETURN] [/WRAP | /NOWRAP)

#include <Constants.au3>

$_bitsadminPath = 'C:\bitsadmin.exe'
$_Pid = Run ( @ComSpec & ' /c "' & $_bitsadminPath & '" /getstate test', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD )

While ProcessExists ( $_Pid )
    $line = StdoutRead ( $_Pid )
    If Not @error And $line = '' Then $line = StdoutRead ( $_Pid, True, True )  
    If Not @error And $line <> '' Then ConsoleWrite ( "STDOUT read : " & $line & @Crlf )
    $line = StderrRead ( $_Pid )
    If Not @error And $line = '' Then $line = StderrRead ( $_Pid, True, True )      
    If Not @error And $line <> '' Then ConsoleWrite ( "STDERR read : " & $line & @Crlf )    
Wend

I get "STDOUT read : Unable to get console input mode - 0x80070006 Descripteur non valide" Posted Image

Perhaps parameters are wrong ?

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I changed the code to this

$foo = Run(@ComSpec & " /c C:\bitsadmin.exe /rawreturn /getstate test > c:\line.txt","C:\",@SW_MINIMIZE)

The only thing I changed was adding " > c:\line.txt" to the end of the command.

The output went to the text file correctly. If I addedd $STDERR_CHILD + $STDOUT_CHILD optional flags, then the text file would have the "Unable to get console input mode - 0x80070006 " error message. So the problem is with $STDERR_CHILD + $STDOUT_CHILD optional flags. I'm going to try your code without it and see what happens.

Link to comment
Share on other sites

Same result ;)

I guess I'm stuck with sending output to text file and reading the text file. This sucks

I search parameters to http://technet.microsoft.com/en-us/library/cc780708(WS.10).aspx

and when i try /help or /? I get this

STDOUT read : 
BITSADMIN version 2.0 [ 6.6.2600.2180 ]
BITS administration utility.
(C) Copyright 2000-2004 Microsoft Corp.

STDOUT read : Unable to get console input mode - 0x80070006
Descripteur non valide

What's the error ? Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I figured it out. I downloaded bitsadmin from Windows XP Support tools, which is an older version. I did some searching and found that there is a newer version in Windows Server 2003 Service Pack 2 32-bit Support Toolslink

This newer version works with no problems.

So the problem wasn't with my script, but with bitsadmin.exe itself.

Thank you for all your help Wakillon

Joe

Link to comment
Share on other sites

I figured it out. I downloaded bitsadmin from Windows XP Support tools, which is an older version. I did some searching and found that there is a newer version in Windows Server 2003 Service Pack 2 32-bit Support Toolslink

This newer version works with no problems.

So the problem wasn't with my script, but with bitsadmin.exe itself.

Thank you for all your help Wakillon

Joe

Thanks for the dowload link, I like work with command line tools ! Posted Image

See myGetCommandLineParameters Utility

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

  • 8 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...