VMware Server2.0@Windowsのサービスの自動起動バッチ

自分が会社で使用しているPCのスペックがしょぼい。

CPUがPentium4の3.00GHz。
メモリが1GB。
泣ける。

だけど、Linuxで開発したいからVMware ServerでCentOS上で開発してるんだけど、兎に角重い。
メモリの使用率が90%以上になったりする。
泣ける。

んで、VMware Serverを使用していない時もVMware Serverで使うサービスが自動で起動しやがるので、使う時だけ起動させるような方法ないかなと探したらありました。
VMware Serverが重いので、起動バッチを作成 | マンダリンケーキのレシピ

だけど、このまま動かしてもエラーになって一部ちゃんと動かない。
なのでいろいろ調べて修正。
結局VMwareServerWebAccessのサービス名が間違っていただけなんだけど、一応晒しておく。

:: VMware Server Service ON/OFF Switch for VMware Server 2.0
:: File Version : 1.1
:: Usage : .\VmWareServiceSwitch.bat
::
::

@echo off
:: Local Variable Mode
setlocal

:: Define Variable
set statetype=0


:: Check Service Status and Define Service Stateus Matrix
::
:: This FLAG(%statetype%;11111) will be Matrix.
:: In future the FLAG will have switch motion each service.
::
sc query "VMAuthdService" | findstr "RUNNING" > NUL
if %errorlevel%==0 set /a statetype=%statetype%+10000
sc query "VMwareHostd" | findstr "RUNNING" > NUL
if %errorlevel%==0 set /a statetype=%statetype%+1000
sc query "VMnetDHCP" | findstr "RUNNING" > NUL
if %errorlevel%==0 set /a statetype=%statetype%+10
sc query "VMware NAT Service" | findstr "RUNNING" > NUL
if %errorlevel%==0 set /a statetype=%statetype%+100
sc query "VMwareServerWebAccess" | findstr "RUNNING" > NUL
if %errorlevel%==0 set /a statetype=%statetype%+1

:: Case stop or start
IF %statetype% == 11111 goto ALLSTOP
IF not %statetype% == 11111 goto ALLSTART


:ALLSTOP
::All VMware Service stop
net stop "VMwareHostd"
net stop "VMAuthdService"
net stop "VMwareServerWebAccess"
net stop "VMware NAT Service"
net stop "VMnetDHCP"
goto END


:ALLSTART
::All VMware Service start
sc query "VMnetDHCP" | findstr "RUNNING" > NUL
if not %errorlevel%==0 net start "VMnetDHCP"
sc query "VMware NAT Service" | findstr "RUNNING" > NUL
if not %errorlevel%==0 net start "VMware NAT Service"
sc query "VMwareServerWebAccess" | findstr "RUNNING" > NUL
if not %errorlevel%==0 net start "VMwareServerWebAccess"
sc query "VMAuthdService" | findstr "RUNNING" > NUL
if not %errorlevel%==0 net start "VMAuthdService"
sc query "VMwareHostd" | findstr "RUNNING" > NUL
if not %errorlevel%==0 net start "VMwareHostd"
goto END


:END
:: If EnvVariable remains, you will cut "::" below line.
::set statetype=

:: End of Local Variable Mode
endlocal

これでOK。
このバッチは、引数無くても自動でOn/Offを切り替えてくれるので優秀です。

作者の方ありがとうございました!

コメント

  1. halt 2009/08/28 11:24:10
    VirtualBoxイイヨー
  2. longkey1 2009/08/29 12:46:57
    virtual box使ってるんですかー。
    一度試そうと思ったけど、結局試せずじまい。
    軽いんですか?
    ちょっと今度試してみますね。

アーカイブ

2012

  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08
  • 09
  • 10
  • 11
  • 12

2011

2010

2009

2008

2007

コンタクト

longkey1[at]gmail[dot]com