Jump to content

Timeout for RunWait?


kpu
 Share

Recommended Posts

Does anyone know if or how you can set a time out on the RunWait Command?

Here's the really short of what I have:

$pw1 = "idontknow"

$pw2 = "istilldontknow"

RunWait(@ComSpec & " /c " & "net use \\" & $line & "\IPC$ /U:Administrator " & $pw1 & " > temp.txt", "", @SW_HIDE)

RunWait(@ComSpec & " /c " & "net use \\" & $line & "\IPC$ /U:Administrator " & $pw2 & " > temp.txt", "", @SW_HIDE)

It takes about 2 minutes for these two commands to check to see if they can connect. Any way to speed it up??

Thanks,

Edited by kpu
Link to comment
Share on other sites

Something like this should be close:

$pw1 = "idontknow"
$pw2 = "istilldontknow"

$cmdStub = @comSpec & " /c " & "net use \\" & $line & "\IPC$ /U:Administrator "
_runWaitTimeout(10, $cmdStub & $pw1 & " > temp.txt", "", @SW_HIDE)
_runWaitTimeout(10, $cmdStub & $pw2 & " > temp.txt", "", @SW_HIDE)

func _runWaitTimeout($timeout, $filename, $workDir = "", $flag = "")

; Returns 0 if finished normally
; Returns PID (> 0) if timeout was reached
; (PID can be used for further manipulation of the process)

    local $pid = run($filename, $workDir, $flag)
    local $start = timerStart()

    do
        processWaitClose($pid, 1)
    until not(processExists($pid)) or timerDiff($start) > ($timeout * 1000)

    return processExists($pid)

endFunc
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...