当我运行我的批处理文件通过大量的it并获得一些信息,如果可以连接到远程cmd,它不工作。
如果echo不能连接,那么它就会打开远程命令外壳,直到我退出到本地命令shell为止。
cd \pstools
psexec.exe @C:\users\chargraves\desktop\inv.txt cmd /c
if errorlevel 0 (
wmic csproduct get version >> \\path\results.txt &
)
if errorlevel 1(
echo "Not accessible"
)我也开始尝试powershell。但是一旦进入远程命令shell,它就会挂起。它不输入密码.“
$computers = Get-Content C:\users\chargraves\Desktop\inv.txt
foreach ($computer in $computers) {
& "c:\pstools\psexec.exe" \\$computer "cmd"
& "wmic csproduct get version >> \\share\results.txt"
}发布于 2016-09-02 14:58:06
我成功地完成了这个任务,而且没有那么复杂。谢谢。
第1批
cd \pstools
psexec.exe @iplist.txt -c batch2.bat批2
wmic command 1 >> results.txt
wmic command 2 >> results.txt
wmic command 3 >> results.txt发布于 2016-09-02 13:12:42
试试这段代码
cd \pstools
psexec.exe @C:\users\chargraves\desktop\inv.txt cmd /c
if %errorlevel%==1 goto fail
REM if errorlevel is 0 then it executes these lines
wmic csproduct get version >> \\path\results.txt
:fail
REM if errorlevel is 1 then it executes the lines bellow
echo "Not Accesible"
ping localhost -n 2 >nulhttps://stackoverflow.com/questions/39278773
复制相似问题