Useful bat command
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的更多相关文章
- BAT command
http://www.cnblogs.com/SunShineYPH/archive/2011/12/13/2285570.html BAT常用命令 1.@ 它的作用是隐藏它后面这一行的命令本身(只能 ...
- (转)Bat Command
1.Echo 命令 打开回显或关闭请求回显功能,或显示消息.如果没有任何参数,echo 命令将显示当前回显设置.语法 echo [{on|off}] [message] Sample篅echo off ...
- 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: ...
- PEAR安装
看到PEAR章节,提到安装PEAR需要go-pear.bat,我机器上的PHP(v7.0.8)目录下,并没有go-pear.bat这个文件,网上查了一遍,怎么说的都有,最后还是在官网上找到解决方案. ...
- Python 3.5安装JPype
使用命令pip install jpype1可安装jpype. 如果出现如下情况: creating build\lib.win-amd64-3.5\jpypex copying jpypex\__i ...
- sso demo ( cas )
1. generate keystore command : keytool -genkey -alias testtomcat -keyalg RSA -keystore "C:\User ...
- WINDOWS下PHP 的pear DB的安装(本地环境:PHP5.4.15+Apache+mysql)
因为需要安装phpunit,要先装pear,网上的教程大多数是以双击go-pear.bat开始,但是我安装的php文件夹里压根没有这个文件. 经过几次搜索之后终于找到了办法. 解决步骤如下: 1.下载 ...
- 基于POI和DOM4将Excel(2007)文档写进Xml文件
刚进公司的training, 下面是要求: Requirements Write a java program to read system.xlsx Use POI API to parse all ...
- Isight 命令行运行任务
说明书参考:https://abaqus-docs.mit.edu/2017/English/DSSIMULIA_Established.htm 不一定对版本.但是大部分还可以. 不对的可以在命令里敲 ...
随机推荐
- C# 使用 GetOleDbSchemaTable 检索架构信息(表、列、主键等)
本文演示如何用 ADO.NET 中 OleDbConnection 对象的 GetOleDbSchemaTable 方法检索数据库架构信息.数据源中的架构信息包括数据库或可通过数据库中的数据源.表和视 ...
- js 字符串中取得第一个字符和最后一个字符
var str = "Hello World";// 删除第一个字符 H,结果为 ello World alert(str.slice(1));// 删除最后一个字符 d,结果为 ...
- 提示用户升级IE6浏览器的办法
IE6一直饱受设计者们的诟病,互联网风云变幻十多年,唯一没变的就是这款在当初被微软内置在winxp系统而又火的不行的浏览器.而如今,在日新月异的网络环境下,IE6却让一个原本美观整洁的网页变得满目疮痍 ...
- C#中String.Empty,“”,NULL的区别
一.String.Empty String类的静态只读字段.定义如下: public static readonly string Empty; 二.“” 被赋值为“”的字符串变量,会在栈上保存一个地 ...
- 如何设置jquery的ajax方法为同步
jax请求默认的都是异步的如果想同步 async设置为false就可以(默认是true) var html = $.ajax({ url: "some.php", async: ...
- MyBatis 配置sql语句输出
版权声明:本文为博主原创文章,未经博主允许不得转载. 此处使用log4j,加入jar包,然后在src路径下加入:log4j.properties文件 填入以下配置就可以打印了 log4j.rootLo ...
- Frenetic QuickInstall
Frenetic a family of network programming languages 官方网站:Frenetic Github:Frenetic QuickInstall 第一步,先安 ...
- Django 1.8安装使用
1.使用pip安装django, pip是什么,如何安装?自行放狗搜 # pip install "django<1.9" 2.创建项目 # django-admin sta ...
- typecho插件编写教程1 - 从HelloWorld说起
typecho插件编写教程1 - 从HelloWorld说起 老高 187 5月25日 发布 推荐 0 推荐 收藏 2 收藏,189 浏览 最近老高正在编写一个关于typecho的插件,由于typec ...
- Linux常用命令-入门
linux 开源安全性高 linux 和 windows 1.同时登陆多用户 2.安全 3.linux没有盘符的概念 /. / root 根目录 4.linux的文件没有扩展名 ...