常用一些服务的启动停止
—sqlserver 相关服务启动—
@echo.服务启动...... @echo off @sc start MSSQLSERVER @sc start SQLSERVERAGENT @sc start MSSQLServerOLAPService @sc start msftesql @sc start MsDtsServer @sc start SQLWriter @echo off @echo.启动完毕! @pause
—sqlserver 相关服务停止—
@echo.服务停止...... @echo off @sc stop SQLSERVERAGENT @sc stop MSSQLServerOLAPService @sc stop msftesql @sc stop MsDtsServer @sc stop SQLWriter @sc stop MSSQLSERVER @echo off @echo.停止完毕! @pause
注:每行命令前有个@,没有也可以
选择性启动一些服务
@echo off rem echo (备注: 自动:auto 手动启动:demand 禁用:disabled ) sc config knbcenter start=disabled sc config PPTVService start=disabled sc config 360rp start=disabled sc config BFAssistantSvc start=disabled (net stop knbcenter)&(net stop PPTVService)&(net stop 360rp)&(net stop BFAssistantSvc) echo 已禁用服务:猎豹浏览器安全中心、PPTVService、360rp、BFAssistantSvc.. echo 选择要开启的服务: echo. echo 0 全部 echo 1 猎豹浏览器安全中心 echo 2 PPTVService echo 3 360 杀毒实时防护 echo 4 BFAssistantSvc echo. set/p var=请选择要开启的服务序号: if %var%==0 (net start knbcenter)&(net start PPTVService)&(net start 360rp)&(net start BFAssistantSvc) if %var%==1 net start knbcenter if %var%==2 net start PPTVService if %var%==3 net start 360rp if %var%==4 net start BFAssistantSvc pause
IIS 相关
IIS 重新启动的 dos 命令:iisreset /restart
启动 IIS:
net start iisadmin (IIS 的整个服务)
net start w3svc (WWW 网页 WEB 服务)
停止 IIS:
net stop iisadmin /y (会自动停止 www、ftp 和 smtp 服务)
如果用的 IIS 自带 FTP 还可以执行
net start MSFtpsvc
命令来启动 FTP
以上命令放到 bat 文件中,再结合 windows 的任务计划就可以实现调度
自动打开和关闭 IE 浏览器
使用批处理命令实现自动打开和关闭 IE 浏览器,把如下两行#号里的内容全部复制,粘贴到记事本,保存为*.bat 文件(*号为文件名)。运行即可。
##################### ping 127.1 -n 3 >nul rem 延时 3 秒 @echo off rem 关闭回显命令 cd C:\Program Files\Internet Explorer\ rem 改变当前目录到 IE 所在目录 rem 打开 ie,30 秒后关闭 start iexplore.exe <a href="http://localhost:8090/" target="_blank" rel="nofollow noopener noreferrer">http://localhost:8090/</a> rem 启动 IE 执行加载路由连接程序 以上地址为例 ping 127.1 -n 30 >nul rem 延时 30 秒 taskkill /im iexplore.exe /f rem 关闭 IE rem 加载路由成功结束 #####################
—–另外附一个清理垃圾的 bat 文件 清理电脑中的垃圾文件.bat—
@echo off echo 正在清除系统垃圾文件,请稍等...... del /f /s /q %systemdrive%\*.tmp del /f /s /q %systemdrive%\*._mp del /f /s /q %systemdrive%\*.log del /f /s /q %systemdrive%\*.gid del /f /s /q %systemdrive%\*.chk del /f /s /q %systemdrive%\*.old del /f /s /q %systemdrive%\recycled\*.* del /f /s /q %windir%\*.bak del /f /s /q %windir%\prefetch\*.* rd /s /q %windir%\temp & md %windir%\temp del /f /q %userprofile%\cookies\*.* del /f /q %userprofile%\recent\*.* del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*" del /f /s /q "%userprofile%\Local Settings\Temp\*.*" del /f /s /q "%userprofile%\recent\*.*" echo 清除系统垃圾文件完成! echo. & pause
批量运行 exe,bat 文件
.\packet\dotnetfx35.exe /passive
.\packet\WindowsXP-KB968930-x86-ENG.exe /passive /norestart
.\packet\WindowsXP-KB942288-v3-x86.exe /passive /forcerestart
把上面的写在一个文本文件中,存成.bat 文件,在同级目录下建一个 packet 的文件夹,里面放入上面三个路径中的 exe 文件,运行该 bat 文件则可以自动运行这三个文件,/passive 是运行选项,有哪些选项可以用 可以在命令行中输入 ****.exe 文件 /?则可以看到所有可用选项
/norestart 是不重启的意思
/forcerestart 是强制重启
如果想批处理运行一系列的 exe 文件,均可以这么做
适合用在批量运行一系列 exe 文件时,如批量安装,安装补丁包
上面有一个问题就是会按顺序一个一个执行,第一个运行完才开始第二个,有时需要按顺序执行一系列的 exe,bat 文件,或者说同时打开则可以这样
:echo ‘automatchworker’
start AutoMatchWorker.bat
:echo ‘ScheduleWorker’
start ScheduleWorker.bat
:echo ‘SmsWork’
start SmsWorker.bat
:echo ‘NotificationWorker’
start NotificationWorker.bat
就会“同时”打开四个程序
完整的一个例子如下
echo ‘kill exe’
taskkill /f /im NotificationWorker.exe
echo ‘copy new exe’
XCOPY /y D:\ManagerTools\NotificationWorker D:\Workering\PushNotificationWorker
echo ‘start exe’
::echo ‘PushNotificationWorker’
start PushNotificationWorker.exe
先杀掉已运行的 exe
copy 新的程序 /y 表示不用提示覆盖
再开启
——–选择性启动某些服务——-
把下面两行#号中间的复制到 bat 文件中,双击运行即可
######### @echo off title 各种服务开启、关闭程序 :allstart cls echo 请选择下面的编号来启动相应的服务 echo 1.VMware 服务开启、关闭 echo 2.SQL Server 2008 服务开启、关闭 echo 3.MySQL 服务开启、关闭 echo 4.Oracle XE 服务开启、关闭 echo 5.Teamviewer 服务开启、关闭 echo 6.Alipay 支付宝 服务开启、关闭 echo e.退出 set in= set /p in=请输入: if "%in%"=="1" goto vmware if "%in%"=="2" goto sqlserver if "%in%"=="3" goto mysql if "%in%"=="4" goto oraclexe if "%in%"=="5" goto teamviewer if "%in%"=="6" goto alipay if "%in%"=="e" goto allclose rem VMware 服务开启、关闭 :vmware echo 1.开启 vm 服务,2.关闭 vm 服务。3.设置为手动。 echo u.回到上层。e.退出。 set in= set /p in=请输入: if "%in%"=="1" goto vmstart if "%in%"=="2" goto vmstop if "%in%"=="3" goto vmsd if "%in%"=="u" goto allstart if "%in%"=="e" goto allclose :vmstart echo "正在启动 VMware 相关开机服务..." rem net start ufad-ws60 net start VMAuthdService net start VMnetDHCP net start "VMware NAT Service" net start VMUSBArbServicepause echo 服务启动完毕! goto vmware :vmstop echo "正在关闭 VMware 相关开机服务..." rem net stop ufad-ws60 net stop VMAuthdService net stop VMnetDHCP net stop "VMware NAT Service" net stop VMUSBArbService echo 服务已关闭! goto vmware :vmsd echo "切换 VMware 开机启动服务为手动中,请稍候..." sc config VMAuthdService start= demand sc config VMnetDHCP start= demand sc config "VMware NAT Service" start= demand sc config VMUSBArbService start= demand echo 成功切换为手动模式! goto vmware rem SQL Server 2008 服务开启、关闭 :sqlserver echo 1.开启 SQLServer 服务,2.关 SQLServer 服务。3.设置为手动。 echo u.回到上层。e.退出。 set in= set /p in=请输入: if "%in%"=="1" goto sqlserverstart if "%in%"=="2" goto sqlserverstop if "%in%"=="3" goto sqlserversd if "%in%"=="u" goto allstart if "%in%"=="e" goto allclose :sqlserverstart echo "正在开启 SQL Server 相关开机服务" rem SQL Server 代理 (MSSQLSERVER2008) net start SQLAgent$MSSQLSERVER2008 rem SQL Full-text Filter Daemon Launcher (MSSQLSERVER2008) net start MSSQLFDLauncher$MSSQLSERVER2008 rem SQL Server (MSSQLSERVER2008) net start MSSQL$MSSQLSERVER2008 rem SQL Server Browser net start SQLBrowser rem SQL Server Integration Services 10.0 net start MsDtsServer100 rem SQL Server VSS Writer net start SQLWriter goto sqlserver :sqlserverstop echo "正在关闭 SQL Server 相关开机服务" net stop SQLAgent$MSSQLSERVER2008 net stop MSSQLFDLauncher$MSSQLSERVER2008 net stop MSSQL$MSSQLSERVER2008 net stop SQLBrowser net stop MsDtsServer100 net stop SQLWriter goto sqlserver :sqlserversd echo "切换 SQL Server 开机启动服务为手动中" sc config SQLAgent$MSSQLSERVER2008 start= demand sc config MSSQLFDLauncher$MSSQLSERVER2008 start= demand sc config MSSQL$MSSQLSERVER2008 start= demand sc config SQLBrowser start= demand sc config MsDtsServer100 start= demand sc config SQLWriter start= demand echo 成功切换为手动模式 goto sqlserver rem MySQL 服务开启、关闭 :mysql echo 1.开启 mysql 服务,2.关闭 mysql 服务。3.设置为手动。 echo u.回到上层。e.退出。 set in= set /p in=请输入: if "%in%"=="1" goto mysqlstart if "%in%"=="2" goto mysqlstop if "%in%"=="3" goto mysqlsd if "%in%"=="u" goto allstart if "%in%"=="e" goto allclose :mysqlstart echo "正在启动 MySQL 相关开机服务..." net start MySQL55 echo 服务启动完毕! goto mysql :mysqlstop echo "正在关闭 MySQL 相关开机服务..." net stop MySQL55 echo 服务已关闭! goto mysql :mysqlsd echo "切换 MySQL 开机启动服务为手动中,请稍候..." sc config MySQL55 start= demand echo 成功切换为手动模式! goto mysql rem Oracle XE 服务开启、关闭 :oraclexe echo 1.开启 oraclexe 必要服务,2.关闭 oraclexe 必要服务。3.设置为手动。 echo u.回到上层。e.退出。 set in= set /p in=请输入: if "%in%"=="1" goto oraclexestart if "%in%"=="2" goto oraclexestop if "%in%"=="3" goto oraclexesd if "%in%"=="u" goto allstart if "%in%"=="e" goto allclose1 :oraclexestart echo "正在启动 oracle xe 必要服务..." net start OracleMTSRecoveryService net start OracleXETNSListener net start OracleServiceXE echo 服务启动完毕! goto oraclexe :oraclexestop echo "正在关闭 oracle xe 相关开机服务..." net stop OracleMTSRecoveryService net stop OracleXETNSListener net stop OracleServiceXE echo 服务已关闭! goto oraclexe :oraclexesd echo "切换 oracle xe 开机启动服务为手动中,请稍候..." sc config OracleMTSRecoveryService start= demand sc config OracleServiceXE start= demand sc config OracleServiceXE start= demand sc config OracleXEClrAgent start= demand sc config OracleXETNSListener start= demand echo 成功切换为手动模式! goto oraclexe rem Teamviewer 服务开启、关闭 :teamviewer echo 1.开启 Teamviewer 服务,2.关闭 Teamviewer 服务。3.设置为手动。 echo u.回到上层。e.退出。 set in= set /p in=请输入: if "%in%"=="1" goto teamviewerstart if "%in%"=="2" goto teamviewerstop if "%in%"=="3" goto teamviewersd if "%in%"=="u" goto allstart if "%in%"=="e" goto allclose :teamviewerstart echo "正在启动 Teamviewer 相关开机服务..." net start TeamViewer7 echo 服务启动完毕! goto teamviewer :teamviewerstop echo "正在关闭 Teamviewer 相关开机服务..." net stop TeamViewer7 echo 服务已关闭! goto teamviewer :teamviewersd echo "切换 TeamViewer 开机启动服务为手动中,请稍候..." sc config TeamViewer7 start= demand echo 成功切换为手动模式! goto teamviewer rem alipay 服务开启、关闭 :alipay echo 1.开启 alipay 服务,2.关闭 alipay 服务。3.设置为手动。 echo u.回到上层。e.退出。 set in= set /p in=请输入: if "%in%"=="1" goto alipaystart if "%in%"=="2" goto alipaystop if "%in%"=="3" goto alipaysd if "%in%"=="u" goto allstart if "%in%"=="e" goto allclose :alipaystart net start AliveSvc net start AlipaySecSvc goto alipay :alipaystop net stop AliveSvc net stop AlipaySecSvc goto alipay :alipaysd sc config AliveSvc start= demand sc config AlipaySecSvc start= demand goto alipay :allclose echo 按任意键退出 pause exit #########
——–end——
相关文章
- ThinkPad x13 Gen1傲腾H10重装系统的麻烦(0)
- Win10系统电脑进入安全模式的四种方法,让你轻松应对各种问题(0)
- 【Python】修改Windows中 pip 的缓存位置与删除 pip 缓存(1)
- 记录问题解决的连接(0)
- ‘%s=%s’ % (k, v) for k, v in params.items(), ^ SyntaxError: Generator expression must be parent(0)