#AutoIt3Wrapper_Outfile_x64=AutoItRunAs.exe #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #include #include #include Local $output = "", $err = "", $cmd=$CmdLine[1], $user=$CmdLine[2], $pass=$CmdLine[3] $PID = RunAs($user, "", $pass, 4, $cmd, "", @SW_HIDE, $STDERR_MERGED) ; Get the handle of the process Local $hProcessHandle = _Process_GetHandle($PID) While ProcessExists($PID) ; Capture the output $output &= StdoutRead($PID) ; Don't kill the CPU Sleep(100) WEnd ; Capture any remaining output $output &= StdoutRead($PID) ; Get the exit code from the process handle, so that this AutoIt executable can exit with the same exit code $exitCode = _Process_GetExitCode($hProcessHandle) ; Write the output from running the command back out, so whoever is watching for the RunAs output can consume it ConsoleWrite($output) Exit($exitCode)