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. WebConfig配置文件详解(转载自逆心的博客)

    <?xml version="1.0"?> <!--注意: 除了手动编辑此文件以外,您还可以使用 Web 管理工具来配置应用程序的设置.可以使用 Visual S ...

  2. 基于HTML5实现的超酷摄像头(HTML5 webcam)拍照功能 - photobooth.js

    在线演示 WebRTC可能是明年最受关注的HTML5标准了,Mozilla为此开发了一套帮助你控制硬件的API,例如,摄像头,麦克风,或者是加速表.你可以不依赖其它的插件来调用你需要的本机硬件设备. ...

  3. hdu

    这道题因为某些位置要重复走,所以不能用标记的方法,但是为了提高效率,可以采用time[]数组和step[]数组来剪枝,很容易想到,当你从一条路劲走到(x,y)处的时间和步骤 比从另一条路劲走到(x,y ...

  4. [转]如何:定义和处理 SOAP 标头

    本文转自:http://msdn.microsoft.com/zh-cn/library/vstudio/8728chd5(v=vs.100).aspx 本主题专门介绍一项旧有技术.现在应通过使用以下 ...

  5. Excel中如何在两个工作表中查找重复数据

    有时我们可能会在两种工作表中查找重复记录,当数据记录很多时,就必须通过简单的方法来实现.下面小编就与大家一起分享一下查看重复记录数据的方法,希望对大家有所帮助. 方法/步骤   为了讲解的需要,小编特 ...

  6. PHP里用户密码的回复和管理

    1). In /etc/my.ini, add skip-grant-tables 2). mysql -u root -p            (no password required) mys ...

  7. Laravel Eloquent 判断取出的结果集是否为空

    在使用Laravel Eloquent模型时,我们可能要判断取出的结果集是否为空,但我们发现直接使用is_null或empty是无法判段它结果集是否为空的. var_dump之后我们很容易发现,即使取 ...

  8. jQuery 判断多个 input checkbox 中至少有一个勾选

    html ( 使用 TP 标签 ) : <volist name="health_tag" id="htag"> <input type=&q ...

  9. 推荐给开发者的20个优秀PHP框架

    推荐给开发者的20个优秀PHP框架 来源:developerslane   时间:2015-01-13 19:48:06   阅读数:111916 分享到:14 [导读] PHP是非常受欢迎并且很有影 ...

  10. mysql通过data目录恢复数据库

    mysql通过data目录恢复数据库 阅读:次   时间:2010-03-24 06:53:30   字体:[大 中 小]     重装系统后,MySQL服务没有了,但是数据库的文件还在,这个时候我想 ...