1.Start and stop the windows services


net stop <service name>
net start <service name>
net pause <service name>
net continue <service name>

A full list of the exact services is found in the registry (run regedit.exe) under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key.

Alternatively, you can perform the stop and start using the name that is showed in the Services Control Panel applet by putting the name in quotes, i.e.

net stop "<service>"
net start "<service>"

2.Display all the Windows services.

net star
sc

3. Query Windows Services status.

net start | find "windwos services nname" 1>nul

if not errorlevel 1 (

echo "windwos services nname" already started.

) else (

echo "windwos services nname" didn't started.

)

sc query "windwos services id"| find /C:"STATE" | find /C:"RUNNING" 1>nul

if not errorlevel 1 (

echo "windwos services nname" already started.

) else (

echo "windwos services nname" didn't started.

)

4. Search String in a file. Findstr is what you needed.

Use spaces to separate multiple search strings unless the argument is prefixed
with /C.  For example, 'FINDSTR "hello there" x.y' searches for "hello" or
"there" in file x.y.  'FINDSTR /C:"hello there" x.y' searches for
"hello there" in file x.y.

findstr /c "string" file
if %errorlevel% equ 1 goto notfound
echo found
goto done
:notfound
        echo notfound
        goto done
:done

Or something like: if not found write to file.
        findstr /c "%%P" file.txt  || ( echo %%P >> newfile.txt )

Or something like: if found write to file.
        findstr /c "%%P" file.txt  && ( echo %%P >> newfile.txt )

Or something like:
        findstr /c "%%P" file.txt  && ( echo found ) || ( echo not found )

最新文章

  1. 105 董婷婷 第一次Sprint总结
  2. jQuery 插件基础
  3. STAR-H1208M集线器不支持同时挂载多个nfs
  4. IOS - ARC改为非ARC
  5. php解析json数组
  6. TPatch动态补丁系统(iOS)
  7. 保护眼睛,开启浏览器的夜间模式 顺便学下!important的作用
  8. SQL_server 的基本操作
  9. Django 1.6 的测试驱动开发
  10. C++写geohash
  11. 转: 谈JAVA_OPTS环境变量不起作用
  12. HashMap源码解析(JDK1.8)
  13. 如何提高使用Java反射的效率?
  14. css 技巧 (持续更新)
  15. ORM框架之------Dapper,Net下无敌的ORM
  16. Chap5:数字货币交易[《区块链中文词典》维京&amp;甲子]
  17. C# 执行CMD命令的方法
  18. 时间序列分析工具箱——tibbletime
  19. Java多线程(一)初步了解
  20. VMware虚拟机克隆CentOS 6.5后网卡修改方法

热门文章

  1. C#SortedList排序列表怎么样逆序输出
  2. jQuery.Validate验证库详解
  3. dpi,ppi,dip,dp,px和sp
  4. IOS第六天(1:scrollView 属性和查看大图)
  5. 学习之痛(数据库-&gt;存储过程和函数)
  6. Java量与变量的区别
  7. NBUT 1602 Mod Three(线段树单点更新区间查询)
  8. 【ArcGis for javascript从零开始】之一 ArcGis加载天地图
  9. Bootstrap页面布局19 - BS提示信息
  10. Memory Allocation in the MySQL Server