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 不一定对版本.但是大部分还可以. 不对的可以在命令里敲 ...
随机推荐
- Xshell选中的同时把内容复制到剪贴板(还可以设置设置文本分隔符)
1.设置对话框 工具 -> 选项 -> 键盘和鼠标 -> 将选定的文本自动复制到剪贴板 2.贴图如下 2.1.打开设置对话框 2.2.设置键盘鼠标,左键复制 2.3.右键粘贴 作者: ...
- C#并行编程--命令式数据并行(Parallel.Invoke)---与匿名函数一起理解(转载整理)
命令式数据并行 Visual C# 2010和.NETFramework4.0提供了很多令人激动的新特性,这些特性是为应对多核处理器和多处理器的复杂性设计的.然而,因为他们包括了完整的新的特性,开 ...
- shiyan2
<?xml version="1.0" encoding="ISO-8859-1"?><web-app xmlns="http:// ...
- Delphi 复习代码
1.取得可文件路径 Path := ExtractFilePath(Application.ExeName); //取得可执行文件路径 TXMLDocument.Create(ExtractFileP ...
- BZOJ 2120 数颜色(带修改的莫队)
2120: 数颜色 Time Limit: 6 Sec Memory Limit: 259 MB Submit: 3478 Solved: 1342 [Submit][Status][Discus ...
- Codeforces Round #375 (Div. 2)——D. Lakes in Berland(DFS连通块)
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- panel,dialog,window组件越界问题汇总
之前分别写过panel,dialog,window三个组件因为拖曳或者reSize造成组件越界而无法还原的问题,两篇文章分别针对拖曳和reSize给出了解决方案.不过根据朋友的反馈,reSize的解决 ...
- CSS权威指南 - 浮动和定位 1
定位 定位的想法很简单元素框相对于正常位置出现在哪里. 定位:static,相对, 绝对, fixed, 继承 static就是默认的位置 相对就是相对于默认位置的偏移.原来的static定位位置依然 ...
- [办公自动化]skydrive onedrive
国内暂时无法访问onedrive,请按如下步骤操作尝试:依次如下:在开始菜单里,单击“所有程序”,找到“附件”,单击找到里面的“记事本”,右键,然后选择“以管理员身份运行”,如果有对话框,选择“是”. ...
- Linux 计划任务 Crontab 笔记与总结(3)Crontab 配置文件
[全局(系统)配置文件] /etc/crontab Linux 主要的配置文件都在 etc 目录下. cd /etc ls cron* vim crontab 进入 cron.d(服务) cd cro ...