【发布时间】:2016-11-01 09:21:35
【问题描述】:
我有一个旧的 CMD 脚本,我想将其转换为在后台运行的 Powershell 脚本,即 CMD 脚本:
@echo off
timeout /t 300 /nobreak
ping -n 1 -i 135 -w 130 192.168.1.250
if errorlevel 1 goto Ende
goto Program
:Program
start "" "C:\Program Files (x86)\XXX\XXX.exe"
Exit
:Ende
Exit
脚本检查路由器是否可ping,如果是,则启动程序。 我对 CMD 或 Powershell 的经验完全为零(请参阅 Goto <. google>
睡眠选项应该与 start-sleep -s 300 一起使用,Ping 检查使用 if (test-connection -computername Server01 -quiet) 但我不完全确定如何围绕 ping 执行 if 语句。
问候
【问题讨论】:
标签: powershell if-statement ping