線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2686
推到 Plurk!
推到 Facebook!

如何知道dos指令已經執行結束

尚未結案
azi
一般會員


發表:10
回覆:39
積分:9
註冊:2002-05-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-11-13 15:49:21 IP:210.241.xxx.xxx 未訂閱
不知道各位是如何在程式啟動 mysql 的。 我是用以下執行指令的方式來啟動的。 WINEXEPCHAR:='mysqld-max --standalone '; WinExec(PCHAR(WINEXEPCHAR),SW_HIDE); WinExec('cmd /C ',SW_SHOWNORMAL); 不過使用者使用過程中如果發生當機, 常常發生 Got error 127 from table handler! mysql資料庫就需要作修復。需要資料檔的目錄中下達 myisamchk --silent --force *.MYI 作修復,我想把他寫在系統裡。問題是如果我把他寫成以下做法 WINEXEPCHAR:='myisamchk --silent --force *.MYI '; WinExec(PCHAR(WINEXEPCHAR),SW_HIDE); WinExec('cmd /C ',SW_SHOWNORMAL); 卻一點作用也沒有。往往還是需要連線到使用者端下達指令。 我參考其他的文章,用執行批次檔的做法試試看。 不過我想知道,要如何知道該dos指令已經執行完成了, 我好做接下去的動作。 --- Azi
------
---
Azi
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-13 15:55:24 IP:147.8.xxx.xxx 未訂閱
Use ShellExecuteEx or CreateProcess, NOT WinExec nor ShellExecute.
azi
一般會員


發表:10
回覆:39
積分:9
註冊:2002-05-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-14 11:24:24 IP:210.241.xxx.xxx 未訂閱
引言: Use ShellExecuteEx or CreateProcess, NOT WinExec nor ShellExecute.
多謝WILLIAMS,我也找到之前你相關問題的解決方法。 我的程式如下: ZeroMemory(@ExecInfo,SizeOf(ExecInfo)); with ExecInfo do begin cbSize := SizeOf(ExecInfo); fMask := SEE_MASK_NOCLOSEPROCESS; lpVerb := 'open'; lpFile := PCHAR(BAT_FILENAME); Wnd := self.Handle; nShow := SW_SHOWNORMAL; end; ShellExecuteEx(@ExecInfo); GetExitCodeProcess(ExecInfo.hProcess,ExitCode); while ExitCode=STILL_ACTIVE do begin GetExitCodeProcess(ExecInfo.hProcess,ExitCode); sleep(10); Application.ProcessMessages; end; Label1.Caption:='修復指令執行完成!'; 但是BAT檔執行完成後,DOS視窗仍然無法關閉,沒有回應。 要自己按X才行。 另外我希望BAT檔,再隱藏模式下執行,我把 SW_SHOWNORMAL 改成 SW_HIDE。 反而造成當機,不能執行 CLICK 的動作。 我當如何修改。 --- Azi
------
---
Azi
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-14 11:57:09 IP:147.8.xxx.xxx 未訂閱
I think you need to create a pif file for your bat file. You could create a shortcut of the bat file, click 'Close on exit' on the Program tab of your shortcut. Or you could use CreateProcess instead, you could redirect I/O using anonymous pipes.
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-11-14 17:55:04 IP:202.39.xxx.xxx 未訂閱
執行 dos 指令後關閉 dos 視窗: http://forum.vclxx.org/topic.php?TOPIC_ID=19762&FORUM_ID=5&CAT_ID=2&Topic_Title=½аݫç¼˦bdelphi ¤¤°õ¦ædos command?&Forum_Title=Database --- Everything I say is a lie.
azi
一般會員


發表:10
回覆:39
積分:9
註冊:2002-05-27

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-11-18 13:41:31 IP:210.241.xxx.xxx 未訂閱
引言: 執行 dos 指令後關閉 dos 視窗: http://forum.vclxx.org/topic.php?TOPIC_ID=19762&FORUM_ID=5&CAT_ID=2&Topic_Title=%BD%D0%B0%DD%AB%E7%BC%CB%A6bdelphi+%A4%A4%B0%F5%A6%E6dos+command%3F&Forum_Title=Database --- Everything I say is a lie.
多謝hagar 版主,不過之前我就是用 WinExec('cmd /C...,只是我必須等到 dos指令執行結束,winexec 的使用無法符合我的需求。 --- Azi
------
---
Azi
azi
一般會員


發表:10
回覆:39
積分:9
註冊:2002-05-27

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-11-18 13:50:19 IP:210.241.xxx.xxx 未訂閱
引言: I think you need to create a pif file for your bat file. You could create a shortcut of the bat file, click 'Close on exit' on the Program tab of your shortcut. Or you could use CreateProcess instead, you could redirect I/O using anonymous pipes.
Thank you.But I don't know what is "pif file",do you mean "Process Interchange Format" file? And i don't know how to redirect I/O using anonymous pipes. Could you show example? --- Azi
------
---
Azi
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-11-18 14:27:15 IP:147.8.xxx.xxx 未訂閱
azi
一般會員


發表:10
回覆:39
積分:9
註冊:2002-05-27

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-11-27 17:48:26 IP:210.241.xxx.xxx 未訂閱
    Thank you to William for applying solutions of my question. I tried pif file solution,but also didn't work as I think. And I don't try createprocess solution yet,because that look some  complex,that will become diffcult to debug. I think another solution.also in bat file. add 'ECHO OFF' let users can not look how instructios working. and at last line add 'ECHO ON' and 'ECHO MESSAGE', program still can not close DOS-MODE window by itself. But i can tell user,when looking at MESSAGE, please close MS-DOS windows.    THAT IS MY SOLUTION.    
引言: Pif file exists since Windows 3.x.... It is used to describe the environment for running a DOS application. http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q131/8/77.asp&NoWebContent=1 http://forum.vclxx.org/topic.php?TOPIC_ID=14800&FORUM_ID=9&CAT_ID=2&Topic_Title=%C3%F6%A9%F3CreateProcess%B3o%AD%D3win%5Fapi&Forum_Title=WinAPI
--- Azi
------
---
Azi
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-11-28 09:09:41 IP:147.8.xxx.xxx 未訂閱
It sounds quite strange 
系統時間:2024-07-07 7:17:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!