![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-04 07:57 |
48,038 topics / 350,123 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » How to use a batch file to detect a process |
| Printable Version 1,265 / 11 |
| Floor1 jention | Posted 2007-04-20 13:40 |
| 初级用户 Posts 23 Credits 60 | |
|
How to use a batch file to determine whether a process exists, and run another batch file
|
|
| Floor2 bjsh | Posted 2007-04-20 20:34 |
| 银牌会员 Posts 621 Credits 2,000 | |
|
wmic process get name | find "the process to check" && the batch file to run
|
|
| Floor3 htysm | Posted 2007-04-20 22:29 |
| 高级用户 Posts 415 Credits 866 | |
|
@echo off
taskklist | find /i "QQ" && echo ok || echo NO pause But this "tasklist" isn't as convenient to use as "WMIC". ^O^ |
|
| Floor4 everest79 | Posted 2007-04-21 02:47 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
wmic can check the exact path
|
|
| Floor5 flyinspace | Posted 2007-04-21 03:50 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
How do you use wmic?? Is there any tutorial?
|
|
| Floor6 everest79 | Posted 2007-04-21 04:15 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
There is a complete one on Microsoft's website. I found it once before, but I didn't pay much attention to it, hehe, it seems to be in BIG5.
|
|
| Floor7 flyinspace | Posted 2007-04-21 04:16 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
BIG5 is fine too... I can read that as well..
I'll go search for it in a bit. |
|
| Floor8 everest79 | Posted 2007-04-21 04:19 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
Actually the built-in help is quite rich. The main thing is some common keywords and this kind of operating mode.
My usual way of learning is to start from examples and then finish it myself. Most of what I look up online is either commands or English that I can't understand, so you should still do more practical applications. |
|
| Floor9 flyinspace | Posted 2007-04-21 04:23 |
| 银牌会员 Posts 517 Credits 1,206 | |
|
Hehe, my batch file skills were built up by practicing with writing scripts :)
I've already written a large script..<junk file cleanup work> :) I caught countless bugs in the middle.. discovered countless problems.. In the end I solved them one by one. As a result, I found that my batch file skills had suddenly gone up a level just like that. |
|
| Floor10 everest79 | Posted 2007-04-21 04:28 |
| 金牌会员 Posts 1,127 Credits 2,564 | |
|
Heh
|
|
| Floor11 luowei144 | Posted 2007-04-21 11:31 |
| 初级用户 Posts 28 Credits 57 | |
|
wimc tutorial addresshttp://www.microsoft.com/technet/prodtechnol/windowsserver2003/zh-chs/library/ServerHelp/749a0c3c-0198-441e-a53f-ad88dbc1f6cb.mspx?mfr=true
Hope everyone learns it soon |
|
| Floor12 waynebeat | Posted 2007-04-21 12:11 |
| 初级用户 Posts 28 Credits 84 | |
|
I just learned to write a little simple VBS, so here's my clumsy attempt
Option Explicit Dim strComputer,wmiNS,wmiQuery,objWMIService Dim colItems,objItem wmiNS = "\root\cimv2" wmiQuery = "Select * from Win32_Process" strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & WmiNS) Set colItems = objWMIService.EXECQuery(WMiQuery) For Each objItem In colItems WScript.Echo objItem.Name & vbtab & objItem.executablepath Next |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |