测试一下
[code ][list=1 ]...[/list ][/code ] 没用- [list=1]
-
-
-
- @echo off
- setlocal enabledelayedexpansion
- :{计算耗时(不考虑小时) 10:35:31.42 [放在开头]
- :: (m*60+s)*1000+s'*10=ms 毫秒
- ::取余去零操作
- set "m=%time:~3,2%"&set "s=%time:~6,2%"&set "ss=%time:~-2%"
- set /a m=1%m% "%%" 100,s=1%s% "%%" 100,ss=1%ss% "%%" 100
- set /a time_start=(%m%*60 + %s%)*1000 + %ss%*10
- :}
-
- ::查看已运行的服务
- echo.查看已运行的服务...
- sc query type^= service|findstr "SERVICE_NAME: DISPLAY_NAME:">tmpinsrv.txt
- start "notepad.exe" tmpinsrv.txt
- pause
- :: 枚举所有服务
- cd.>tmpsrv.txt
- sc query type^= service state^= all|findstr /r /C:"SERVICE_NAME:">>tmpsrv.txt
- echo 正在运行 稍后...
- ::设置启动类型:关闭
- for /f "tokens=2 delims= " %%a in (tmpsrv.txt) do sc config %%a start= DISABLED>nul
- ::for /f "tokens=2 delims= " %a in (tmpsrv.txt) do sc config %a start= AUTO>nul
-
- ::打开必要的服务:
- (rem 显示名: remote Procedure Call (RPC)
- sc config RpcSs start= AUTO
- rem 显示名: Plug and Play (随插随用)
- sc config PlugPlay start= AUTO
- sc config AudioSrv start= AUTO
- sc config Eventlog start= AUTO
- rem 显示名: Network Connections
- sc config Netman start= DEMAND
- rem 显示名: Telephony (电话语音)
- sc config TapiSrv start= DEMAND
- rem 显示名: Remote Access Connection Manager(PPPOE)
- sc config RasMan start= DEMAND
- rem 显示名: Windows Installer (Windows 安装程序)
- sc config MSIServer start= DEMAND
- rem 显示名: Telnet
- sc config TlntSvr start= DEMAND
- rem 显示名: NVIDIA Display Driver Service (N显卡驱动)
- sc config NVSvc start= AUTO
- rem 显示名: Kaspersky Internet Security 7.0 (卡巴斯基)
- sc config AVP start= DEMAND
- )>nul
-
- set /p "choice=需要打印服务?(y|n)"
- if /i "%choice%"=="y" (sc config Spooler start= AUTO)
- set /p "choice=需要使用扫描仪/摄像头?(y|n)"
- if /i "%choice%"=="y" (sc config stisvc start= DEMAND)
- set /p "choice=需要DCOM/COM+服务?(y|n)"
- if /i "%choice%"=="y" (sc config DcomLaunch start= AUTO & sc config EventSystem start= DEMAND)
- set /p "choice=IP地址自动获得(DHCP)?(y|n)"
- if /i "%choice%"=="y" (sc config dhcp start= AUTO)
- set /p "choice=ASP.NET 玩大型网游?(y|n)"
- if /i "%choice%"=="y" (sc config aspnet_state start= DEMAND)
-
- ::for /f "tokens=1 delims= " %%a in (tmpsrv.txt) do sc start %%a
-
-
- :{计算耗时(不考虑小时) 10:35:31.42 [放在结尾]
- set "m=%time:~3,2%"&set "s=%time:~6,2%"&set "ss=%time:~-2%"
- set /a m=1%m% "%%" 100,s=1%s% "%%" 100,ss=1%ss% "%%" 100
- set /a time_end=(%m%*60 + %s%)*1000 + %ss%*10
- set /a time_lost=%time_end%-%time_start%
- ::echo ::耗时: %time_lost%ms (毫秒)>>"%FILENAME%"
- echo 耗时: %time_lost%ms (毫秒)
- :}
- echo 任务结束
- pause>nul
- del /q tmpsrv.txt tmpinsrv.txt
- exit /b
- [/list]
复制代码
[ 本帖最后由 hfg1977 于 2010-10-16 18:02 编辑 ] |