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 不一定对版本.但是大部分还可以. 不对的可以在命令里敲 ...
随机推荐
- loadView、viewDidLoad及viewDidUnload的关系
标题中所说的3个方法,都是UIViewController的方法,跟UIViewController的view属性的生命周期息息相关.接下来我会一一阐述它们的作用以及它们之间的联系. loadVi ...
- php中alert弹出时单双引号问题
php代码中单双引号问题是个很重要的问题,使用不当会造成很多麻烦.先记录一下今天写alert遇到的麻烦.我做登录的时候,成功时想弹出个提示说登录成功.写alert语句时不显示.其实就是单双引号弄得不对 ...
- Java栈与堆一篇好文
http://blog.csdn.net/zhangao0086/article/details/6347342
- linux进程用户内存空间和内核空间
When a process running in user mode requests additional memory, pages are allocated from the list of ...
- dig理解dns主备 - 阿权的书房
dns的解析一般都授权两个以上,防止单点故障. 比如阿权的书房的域名 www.aslibra.com,授权两台ns.aslibra.com 和 ns2.aslibra.com,如果单点故障会怎么样呢? ...
- 2016.05.03,英语,《Vocabulary Builder》Unit 21
sub, means 'under', as in subway, submarine, substandard. A subject is a person who is under the aut ...
- 各种demo——CI框架学习
各种demo——CI框架学习 寒假学习一下CI框架,请各位多多指教! 一.CI的HelloWorld! 注意:CI禁止直接通过文件目录来访问控制器. ./application/controlle ...
- JNDI学习总结(三)——Tomcat下使用Druid配置JNDI数据源
com.alibaba.druid.pool.DruidDataSourceFactory实现了javax.naming.spi.ObjectFactory,可以作为JNDI数据源来配置. 一.下载D ...
- processor, memory, I/O
COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION 3.3 INTERCONNECTION S ...
- 微信公众账号开发教程(一) 基本原理及微信公众账号注册 ——转自http://www.cnblogs.com/yank/p/3364827.html
微信公众账号开发教程 基本原理 在开始做之前,大家可能对这个很感兴趣,但是又比较茫然.是不是很复杂?很难学啊? 其实恰恰相反,很简单.为了打消大家的顾虑,先简单介绍了微信公众平台的基本原理. 微信服务 ...