Jump to content

How to get the result from a Dos command


xManh
 Share

Recommended Posts

I'm fairly sure you may get a return of 1 or 0 by running @ComSpec directly.

$result = Run(@ComSpec & " /c " & $command, "", @SW_HIDE)
MsgBox(0, '', $result)
oÝ÷ Ø&uø¥z)Ü¢jZ®+(Ƨ­ën®{Ú®)à{oj[&®éçxr¦jwDv+B×âçë­ën®{Úç¬mì¨ÛazX¦ÚÑ©Ý×ú®¢×¶§Áó槵§Y¨­{-y§h}§N«zÛ«ö¥¹çë¢dn+-êk¡Ç¬°è~Ø^
¥ç¢{(êk¡Ç¬²)íç±jjexò¢ë¬y§Y¨­¶§ÚÞ¶êç²Ø^zºè®W¯zWë¢kayÊ&©ÝJ¨¹Æ§~ÞÅ©©è¶Ø^zºè®W¯zWë¢cDMDjëh×6$ExtCmd = "NET USE X: \\MyServer\MyShare * /USER:MyUser /PERSISTENT:NO"
$RetCode = RunWait($ExtCmd, @TempDir, @SW_MINIMIZE)
If $RetCode = 0 Then
     MsgBox(64, "Success", "Successfully mapped X: drive.")
Else
     MsgBox(16, "Error", "Error mapping X: drive, ERRORLEVEL = " & $RetCode)
EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks for recommendation MHz

You still haven't said what $command was in your first example. If it outputs some kind of status to StdOut, then you can use Run() with $STDOUT_CHILD and the StdOutRead() function. Just another option... :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

You still haven't said what $command was in your first example. If it outputs some kind of status to StdOut, then you can use Run() with $STDOUT_CHILD and the StdOutRead() function. Just another option... :lmao:

Heh...I like the stdout option, but have found an issue with it. Say your running the command 'findstr', and the file you are doing the search on does not contain the string you are looking for, a race condition is created. I've yet to find an elegant way around this, but I am still very new to autoit.

Link to comment
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
 Share

  • Recently Browsing   0 members

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