Re: [請益] php能執行bat檔嗎

看板PHP作者 (archer)時間15年前 (2010/09/09 10:06), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/3 (看更多)
※ 引述《davidou (老歐 ! 月夜雪嵐)》之銘言: : 我想寫一個自動關機的網頁 : 所以應該會寫一個bat檔 : 我想問 php有辦法去執行那個.bat的檔案嗎 : 假設可以另外還有個問題就是 : 我要是在別台電腦 開了這個網頁 : 那被關機的電腦 應該是sever那台電腦是吧.. : 這方面似乎沒甚麼涉略 不太知道該怎下手.... 沒有實作過,查了一下手冊 http://php.net/manual/en/function.system.php // Outputs all the result of shellcommand "ls", and returns // the last output line into $last_line. Stores the return value // of the shell command in $retval. $last_line = system('ls', $retval); 上述的範例會將 shell 底下 ls 的命令輸出結果回傳到 $last_line 所以合理推測,可以用這樣的方式去呼叫 .bat 檔 system('<path_to_bat>') 如果可以成功呼叫 bat 檔,那接下來就是蛋糕一塊了 bat 內容: psshutdown \\<server_ip> -t 600 -f -s [-u xxx -p xxx] 參數說明: -t 600 設定時間,600秒 -f 強制 -s 關機 註:你必須有管理者權限,必要時必須撘配以下兩個參數: -u 帳號 -p 密碼 psshutdown 是工具程式,這邊可以下載 http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.218.139.174

09/10 22:18, , 1F
psshutdown 和 shutdown 有什麼差別
09/10 22:18, 1F
文章代碼(AID): #1CY44DlI (PHP)
討論串 (同標題文章)
文章代碼(AID): #1CY44DlI (PHP)