最近安装了很多程序啊,发现有蛮多程序都没在随机启动的服务,如果每个都要改成手动,然后再停止,实在是太浪费时间。而且,像VMware这类的服务,如果要正常使用的时候,要运行三四个服务,手动开启,用完之后再手动关闭,实在是太麻烦。
为了解决这个麻烦,自己照着批处理的语言,写了一个批处理,把服务设置为手动,然后等需要的时候运行这个批处理,按照里面的提示进行选择,开启或关闭某些服务。
具体效果如下图所示:
我自己这边加了VMware、MySQL、SQL Server 2008、Oracle XE、TeamViewer。如果自己相加的话,可以自己照着写一下。
其中用到的语句其实蛮简单的。这里就只写几个比较关键的。
net start 服务名 开启某服务
net stop 服务名 关闭某服务
注:如果服务名有空格,则用双引号括起来。另外服务名不是服务显示的名称,你要右键服务属性才能看到服务名。有时候显示的名称就是服务名。
sc config 服务名 start= 属性(demand 手动、auto 自动、disable 禁用) 设置该服务的启动形式
我写的具体代码如下:
View Code TEXT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | @echo off title 各种服务开启、关闭程序 :allstart cls echo Laycher's Blog www.laycher.com 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 |
把上面的代码保存在记事本里,然后重命名为XXX.bat,运行就可以了。提醒:有时候会被杀毒软件误杀。。。无语。。。。
想了想,发现支付宝那个服务确实挺讨厌
这个收了
这很有用哦,我也在用VMware,一直开着,影响主机速度,不开启时有要用