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 )

Useful bat command的更多相关文章

  1. BAT command

    http://www.cnblogs.com/SunShineYPH/archive/2011/12/13/2285570.html BAT常用命令 1.@ 它的作用是隐藏它后面这一行的命令本身(只能 ...

  2. (转)Bat Command

    1.Echo 命令 打开回显或关闭请求回显功能,或显示消息.如果没有任何参数,echo 命令将显示当前回显设置.语法 echo [{on|off}] [message] Sample篅echo off ...

  3. How to generate file name according to datetime in bat command

    On the command line, note: must copy and paste below lines of code and then execute them one by one: ...

  4. PEAR安装

    看到PEAR章节,提到安装PEAR需要go-pear.bat,我机器上的PHP(v7.0.8)目录下,并没有go-pear.bat这个文件,网上查了一遍,怎么说的都有,最后还是在官网上找到解决方案. ...

  5. Python 3.5安装JPype

    使用命令pip install jpype1可安装jpype. 如果出现如下情况: creating build\lib.win-amd64-3.5\jpypex copying jpypex\__i ...

  6. sso demo ( cas )

    1. generate keystore command : keytool -genkey -alias testtomcat -keyalg RSA -keystore "C:\User ...

  7. WINDOWS下PHP 的pear DB的安装(本地环境:PHP5.4.15+Apache+mysql)

    因为需要安装phpunit,要先装pear,网上的教程大多数是以双击go-pear.bat开始,但是我安装的php文件夹里压根没有这个文件. 经过几次搜索之后终于找到了办法. 解决步骤如下: 1.下载 ...

  8. 基于POI和DOM4将Excel(2007)文档写进Xml文件

    刚进公司的training, 下面是要求: Requirements Write a java program to read system.xlsx Use POI API to parse all ...

  9. Isight 命令行运行任务

    说明书参考:https://abaqus-docs.mit.edu/2017/English/DSSIMULIA_Established.htm 不一定对版本.但是大部分还可以. 不对的可以在命令里敲 ...

随机推荐

  1. elasticsearch2.2 集群搭建各种坑

        目前生产环境的es版本是1.0版本,需要升级到最新的2.2版本,于是在测试环境进行部署集群测试,在测试过程中遇到的坑相当多,下面详细介绍下.       1. 版本升级到2.2后,必须建一个单 ...

  2. NSJSONSerialization介绍

      ios5中apple增加了解析JSON的api——NSJSONSerialization.网上已经有人做过测试,NSJSONSerialization在效率上完胜SBJSON.TouchJSON. ...

  3. hdu A计划

    这道题是一道bfs的题目,因为题目中给的数据很小,所以可以采用优先队列的方式来简化处理.这道题在搜索的过程中要注意map1的不同层次的转换,即对'#'的理解.之前wa了两次是因为我考虑了如果上下两层对 ...

  4. nova help network-create

    chen@controller:~$ nova help network-create usage: nova network-create [--fixed-range-v4 <x.x.x.x ...

  5. Foreach 与 Foreach-Object 的区别

    下面两个实例可以看出:   Get-ADGroupMember -Identity "CN=gAPCHN-HGZ-IE10-Users,OU=Groups,OU=Hangzhou - Chi ...

  6. 【贴图】网友 snoopy 用《iHMI43 液晶模块》做的界面给大家看看

    请大家欣赏! iHMI43 4.3寸液晶模块购买地址: http://item.taobao.com/item.htm?id=20508376359

  7. PHP $_SERVER 详解

    元素/代码 描述 $_SERVER['PHP_SELF'] 当前执行脚本的文件名,与 document root 有关. $_SERVER['GATEWAY_INTERFACE'] 服务器使用的 CG ...

  8. Linux权限问题

    Linux中各个用户对文件和目录的权限有三种: r: 读 w:写 x:执行 各个权限的意义: 文件 r:可以读取文件的内容 w:编辑文件内容 x:执行该文件 目录 r:列出该目录下的内容,即使用ls命 ...

  9. coreDate 简化版

    建表: 自动生成: 代码: // // RootViewController.m // coreDate 简化版 #import "RootViewController.h" #i ...

  10. 如何查询MySql日志

    如何查询MySql日志 分类: mysql2012-02-23 19:14 26756人阅读 评论(2) 收藏 举报 mysqlcommandprintingserversocketoutput 今天 ...