Jump to content
Sign in to follow this  
hiteshluthra

Command in autoit not working

Recommended Posts

hiteshluthra

Hi all genius,

Im trying to get output on GUI of command dsquery computer -name (computername to which user is logged on)

local $OU = Run(@ComSpec & " /c dsquery computer -name %computerName%", @SystemDir, @SW_HIDE)

but getting weird output, can you pls help

Share this post


Link to post
Share on other sites
wakillon

Try this :

#include <Constants.au3>

$_Pid = Run ( @ComSpec & " /c dsquery computer -name " & @ComputerName, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD )
Global $_StderrRead='', $_StdoutRead=''

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

Edit : oups i forget the flag...

Edited by wakillon

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

Share this post


Link to post
Share on other sites
hiteshluthra

Thanks for responding, its still not working

Dim $Map,$Mac,$OU

$Map=DriveMapGet("H:")

$OU = Run ( @ComSpec & " /c dsquery computer -name " & @ComputerName, @SystemDir, @SW_HIDE )

$Label6 = GUICtrlCreateLabel("OU Path", 32, 360, 70, 25)

GUICtrlSetFont(-1, 12, 400, 0, "Century Gothic")

$Input6 = GUICtrlCreateInput($OU, 232, 360, 145, 21)

Kindly see the attachment this is what the output is on GUI, m i doing something wrong ?

post-56306-0-88275100-1301037336_thumb.p

Share this post


Link to post
Share on other sites
wakillon

Your picture show the pid of process...

What give the consolewrite of my example ?


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

Share this post


Link to post
Share on other sites
hiteshluthra

your code gives /ErrorStdOut error

i need to get results in GUI as a result shud be like this

"CN=LD6D714BS,OU=Managed Workstations,OU=Workstations,DC=server,DC=com"

Share this post


Link to post
Share on other sites
wakillon

When i try this, i get an output in a text file, but your command parameters give nothing !

Are you sure of them ? Posted Image

RunWait ( @ComSpec & " /c DSQuery /? >c:\output.txt", @SystemDir, @SW_HIDE )
Run ( 'notepad c:\output.txt' )
Edited by wakillon

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

Share this post


Link to post
Share on other sites
hiteshluthra

i need the output of the command

$OU = dsquery computer -name LD6D714BS ----->>> syntax of command needs to be corrected

and needs the output on input box

$Input6 = GUICtrlCreateInput($OU, 232, 360, 145, 21)

Tool is fully prepared except this , pls help

can we chat directly through googletalk etc. ?

Share this post


Link to post
Share on other sites
wakillon

But $OU is the pid's process, not the output !

I show you 2 ways for get it, but unsuccessfully...

Edited by wakillon

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

Share this post


Link to post
Share on other sites
hiteshluthra

i think im not understanding what you say or im not able to get you on the point i need

i need to run command

something like this

Run ( @ComSpec & " /c dsquery computer -name " & @ComputerName, @SystemDir, @SW_HIDE )

and output should come to GUI

output should be

"CN=LD6D714BS,OU=Managed Workstations,OU=Workstations,DC=server,DC=com"

how to get it done ?

Share this post


Link to post
Share on other sites
AdamUL

@hiteshluthra

Here you go, try this:

#include <Constants.au3>
$iPIDOU = Run('dsquery computer -name ' & @ComputerName, @SystemDir, @SW_HIDE, $STDOUT_CHILD)
ProcessWaitClose($iPIDOU)
$sOU = StringStripWS(StdoutRead($iPIDOU), 3) ;Remove leading and trailing white spaces from the output.

Make sure dsquery is in your system PATH.

@wakillon

You didn't put the options flags, $STDOUT_CHILD + $STDERR_CHILD or $STDERR_MERGED, at the end of your Run call in your first reply. That is why your code didn't work correctly.

The DS tools, dsquery and others, are part of the Windows Server Administration Tools Pack, which you can download from Microsoft. There are versions for XP and Windows 7.

Adam

Share this post


Link to post
Share on other sites
hiteshluthra

YES YES YES YES , you all are genius......................it did work.............i was waiting for long to work it and you made it simple

i have done small mistake and you got it

you are genius

THanks a looooooooooooooooooooooooooooooooooooooooooooooooooootttttttttttttttttttttttttttttttttttttt for help

Share this post


Link to post
Share on other sites
AdamUL

Glad I could help.

Adam

Share this post


Link to post
Share on other sites
wakillon

@wakillon

You didn't put the options flags, $STDOUT_CHILD + $STDERR_CHILD or $STDERR_MERGED, at the end of your Run call in your first reply. That is why your code didn't work correctly.

The DS tools, dsquery and others, are part of the Windows Server Administration Tools Pack, which you can download from Microsoft. There are versions for XP and Windows 7.

Adam

You're right, I put the include, but i forgot them ! Posted Image


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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×