我有以下代码似乎无法正常工作,但是当我打开命令提示符并运行命令时它会起作用:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="ping.php" method="POST">
<label for="pc_number">Provide target PC names (separate with ":"): </label>
<input type="text" name="pc_number" id="pc_number">
<input type="submit">
</form>
<?php if(empty($_POST["pc_number"])==FALSE)
{
$number = explode(":", $_POST["pc_number"]);
foreach($number as $pc)
{
$restart = shell_exec("shutdown /r /m {$pc} /t 0");
echo "Restarting {$pc}... <br>\n";
echo $restart;
}
}
?>
</body>
为什么它在命令提示符下有效,但在我通过PHP执行时却没有?我正在尝试远程重启Windows PC。