![]() |
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-11-10 20:07 |
47,815 topics / 349,930 posts / today 0 new / 48,291 members |
| DOS批处理 & 脚本技术(批处理室) » [Help] How to use batch processing to start and stop services |
| Printable Version 2,716 / 22 |
| Floor16 lxmxn | Posted 2007-01-24 06:42 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by jasonwang at 2007-1-23 14:22: Go to the 4th floor of this post to have a look. |
|
| Floor17 agesbgfe | Posted 2007-01-24 10:50 |
| 新手上路 Posts 1 Credits 2 | |
| Floor18 hangyug | Posted 2007-01-24 12:07 |
| 初级用户 Posts 43 Credits 99 | |
|
RE: jasonwang
&& means that if the command is executed successfully, the command following it will be executed || is exactly the opposite of &&, meaning that if the command fails to execute, the command following it will be executed |
|
| Floor19 jasonwang | Posted 2007-01-24 23:15 |
| 初级用户 Posts 54 Credits 122 | |
|
Thanks to the explanation of the upstairs, I didn't succeed in the test under 03. Is this command invalid when the service is in the disabled state?
|
|
| Floor20 jasonwang | Posted 2007-01-24 23:40 |
| 初级用户 Posts 54 Credits 122 | |
|
C:\>sc query tlntsvr
SERVICE_NAME: tlntsvr TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 C:\>services.bat Press any key to continue . . . C:\>sc query tlntsvr SERVICE_NAME: tlntsvr TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 C:\> @echo off for /f "delims=" %%i in ('sc query tlntsvr^|find "state"') do ( echo %%i|find /i "running" && ( sc stop tlntsvr sc config tlntsvr start^=disabled) || ( sc config tlntsvr start^=auto sc start tlntsvr) ) pause |
|
| Floor21 bob1989 | Posted 2007-01-25 00:09 |
| 中级用户 Posts 144 Credits 322 | |
|
It's okay with the net start command. SC is not available under WIN2000.
|
|
| Floor22 lxmxn | Posted 2007-01-25 00:41 |
| 版主 Posts 4,938 Credits 11,386 | |
Originally posted by jasonwang at 2007-1-24 10:40: There is an error in your code. Try copying the code I wrote. |
|
| Floor23 jasonwang | Posted 2007-01-25 02:47 |
| 初级用户 Posts 54 Credits 122 | |
|
Got it, add /i after the first find. There should be a space before start= auto. Hehe, thank you everyone
|
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |