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. 简单查看tomcat中部署java服务的内存使用情况

    vim tomcat_mem.sh NAME=$1 #部署项目名称 #PID=`ps -ef|grep tomcat|grep $NAME|awk '{print $2}'` PID=`ps -ef| ...

  2. FreeBSD Intel SYSRET Kernel Privilege Escalation Exploit

    /* * FreeBSD 9.0 Intel SYSRET Kernel Privilege Escalation exploit * Author by CurcolHekerLink * * Th ...

  3. Win2K3一句话开3389

    网上流传了很多开3389的exe小工具,还有读写注册表的bat批处理,有的是操作注册表,有的是操作各种组件这里提供一个不会被拦截,而且可以使用的开3389的cmd一句话: wmic RDTOGGLE  ...

  4. Angualar:指令大全

    指令: 内置渲染指令 内置事件指令 内置节点指令 自定义指令 restrict template replace属性 templateUrl属性 trnsclude priorty terminal属 ...

  5. MongoDB命令模式下的条件过滤总结

    db.tb1.find() //查询全部,用it查看下一页.db.tb1.find({"age":1}) //查询年龄==1的记录db.tb1.find({},{"age ...

  6. Mininet实验 OpenFlow1.3协议基于Mininet部署与验证

    参照:OpenFlow1.3协议基于Mininet部署与验证 安装过程,参考原文. 实验 使用ifconfig查看本机IP地址:192.168.1.101 进入OpenDayLight界面,cd到bi ...

  7. Redis 笔记与总结4 set 和 zset 类型

    (一)set 类型 set 是集合是 string 类型的无序集合. set 元素最大可以包含(2 的 32 次方)个元素.set 的是通过 hash table 实现的,所以添加.删除和查找的复杂度 ...

  8. github中non-fast-forward错误的解决

    参考文献 1.http://www.linuxidc.com/Linux/2012-04/58985.htm 2.http://ihower.tw/blog/archives/2620 3.http: ...

  9. jdbc 日期时间相关的类型

    jdbc 日期时间相关的类型 1.sql.Date sql包中的日期类Date是util包中Date类的子类,实际上也是util.Date类的子集.它只处理年月日,而忽略小时和分秒,用以代表SQL的D ...

  10. MySQL问题汇总(持续更新)

    1.This function has none of DETERMINISTIC, NO SQL 原因: Mysql如果开启了bin-log, 我们就必须指定我们的函数是否是 1 DETERMINI ...