表示名 | サービス名 |
VMware Authorization Service | VMAuthdService |
VMware DHCP Service | VMnetDHCP |
VMware NAT Service | VMware NAT Service |
VMware USB Arbitration Service | VMUSBArbService |
:: VMWare関連のサービスを起動/停止するもの :: 対象サービス->VMAuthdService, VMnetDHCP, VMware NAT Service, VMUSBArbService @echo off :: 環境変数のローカライズをする setlocal :: フラグ変数の宣言 set statetype=0 :: サービスの状態を確認してフラグを立てる sc query "VMAuthdService" | findstr "RUNNING" > NUL if %errorlevel%==0 set /a statetype=%statetype%+1000 sc query "VMnetDHCP" | findstr "RUNNING" > NUL if %errorlevel%==0 set /a statetype=%statetype%+100 sc query "VMware NAT Service" | findstr "RUNNING" > NUL if %errorlevel%==0 set /a statetype=%statetype%+10 sc query "VMUSBArbService" | findstr "RUNNING" > NUL if %errorlevel%==0 set /a statetype=%statetype%+1 :: フラグが全て立ってたら停止処理、それ以外なら起動処理 if %statetype% == 1111 ( goto ALLSTOP ) else ( goto ALLSTART ) :ALLSTOP :: サービスを停止する net stop "VMAuthdService" net stop "VMnetDHCP" net stop "VMware NAT Service" net stop "VMUSBArbService" :: VMWareのNICを無効にする netsh interface set interface "VMware Network Adapter VMnet1" disabled netsh interface set interface "VMware Network Adapter VMnet8" disabled goto END :ALLSTART :: 起動されてないサービスを起動する sc query "VMAuthdService" | findstr "RUNNING" > NUL if not %errorlevel%==0 net start "VMAuthdService" 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 "VMUSBArbService" | findstr "RUNNING" > NUL if not %errorlevel%==0 net start "VMUSBArbService" :: VMWareのNICを有効にする netsh interface set interface "VMware Network Adapter VMnet1" enabled netsh interface set interface "VMware Network Adapter VMnet8" enabled goto END :END :: 環境変数のローカライズの終了 endlocal |