adding a timeout to batch/powershell

前端 未结 5 1367
面向向阳花
面向向阳花 2020-12-10 14:05
$fullnamexp = ((net user $winxp /domain | Select-String \"Full Name\") -replace \"Full Name\",\"\").Trim();

If $winxp cannot be found,

5条回答
  •  盖世英雄少女心
    2020-12-10 14:48

    net doesn't explicitly allow you to set a time out on it's operations, but you could check out this link on changing the ipv4 timeout for your sockets:

    http://www.cyberciti.biz/tips/linux-increasing-or-decreasing-tcp-sockets-timeouts.html

    The only thing else I could imagine is spawning a worker thread but I don't even know if that's possible in bash, I'm not fluid enough in it to answer that; plus it opens you up to sync problems and all sorts of multi threaded issues beyond what you're trying to accomplish quickly in a bash script to begin with! :P

提交回复
热议问题