Jump to content

Recommended Posts

Posted

For example I run a Dos command

Run(@ComSpec & " /c " & $command, "", @SW_HIDE)
    return $result

How to know if the command is successful?

thnx

Posted (edited)

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)

A cmd file in comparison can return varing int value from running a command.

:)

Edit:

Cmd file can use return values beyond the limit of 0 and 1.

Edited by MHz
Posted

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
Posted

Well I see. But is there a way to track the progress If I don't runwait.

Like Initget, I can choose 1 to download at background?

Posted

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
  • 2 weeks later...
Posted

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.

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
×
×
  • Create New...