普遍的vm服务启动

简介: 虽然可以说这玩意都是换汤不换药查重率估摸着也得70%,但整体还是自己的包括注册表中寻找地址的再运行的这种偷懒想法(自己用的挺流畅)。主要是吧,不想开机启动,又懒得去服务里手动。
@echo off
setlocal EnableDelayedExpansion
color 3e
title 请授权管理员模式
PUSHD %~DP0 & cd /d "%~dp0"%1 %2
mshta vbscript:createobject("shell.application").shellexecute("%~s0","goto :runas","","runas",1)(window.close) & goto :eof & exit:runas
set /a ap =0setvmd=VMnetDHCP
setvmas=VMAuthdService
setvmus=VMUSBArbService
setvmns=VMware NAT Service
setstopSv=停止指令
setstartSv=启动指令
setnoSv=未执行
setcharText=##################################################setcharText2=#################################setcharText3=##                             ##setdhcp=%vmd% %startSv%
setauthd=%vmas% %startSv%
setusbarb=%vmus% %startSv%
setnat=%vmns% %startSv%
setdhcps=%vmd% %stopSv%
setauthds=%vmas% %stopSv%
setusbarbs=%vmus% %stopSv%
setnats=%vmns% %stopSv%
setvmNoService=未检测到VM服务已自动取消 按任意键关闭...
setvmOver=VMware服务操作执行完成 按任意键关闭...
sc query %vmas% > nul && cls && goto head3 || goto noService
:head3
echo %charText2%
echo %charText2%
echo %charText3%
echo##     %vmd%               ##echo##     %vmas%          ##echo##     %vmus%         ##echo##     %vmns%      ##echo %charText3%
echo %charText2%
echo %charText2%
echo %charText3%
echo##         1 启动服务          ##echo##         2 停止服务          ##echo %charText3%
echo##       额外输入自动检查      ##echo##       并启动或停止服务      ##echo %charText3%
echo %charText2%
echo %charText2%
echo %charText3%
echo##         请输入1或2          ##echo %charText3%
if %ap% equ 0 (goto input3) else (goto body3)
:input3
::Rem CHOICE /C 123 /N /T 10 /D 3 /M "请输入1或2"  %ERRORLEVEL% ;选项1,2,3 ;隐藏多余提示;10秒自动选择3;提示语;取值
set /p ap=cls
goto head3
:body3
echo %charText3%
echo##          已输入 %ap:~0,1%           ##echo %charText3%
echo %charText2%
echo %charText2%
if %ap:~0,1% equ 1 (goto startService) elseif %ap:~0,1% equ 2 (goto stopService) else (goto scService)
:startService
echo %charText%
net start %vmd% && echo %dhcp% || echo %dhcp%%noSv%
echo %charText%
net start %vmas% && echo %authd% || echo %authd%%noSv%
echo %charText%
net start %vmus% && echo %usbarb% || echo %usbarb%%noSv%
echo %charText%
net start"%vmns%" && echo %nat% || echo %nat%%noSv%
echo %charText%
goto setVMhost
:stopService
echo %charText%
net stop %vmd% && echo %dhcps% || echo %dhcps%%noSv%
echo %charText%
net stop %vmas% && echo %authds% || echo %authds%%noSv%
echo %charText%
net stop %vmus% && echo %usbarbs% || echo %usbarbs%%noSv%
echo %charText%
net stop"%vmns%" && echo %nats% || echo %nats%%noSv%
echo %charText%
goto exit_this
:scService
echo %charText%
sc query %vmd% && net stop %vmd% && echo %dhcps% || net start %vmd% && echo %dhcp%
echo %charText%
sc query %vmas% && net stop %vmas% && echo %authds% || net start %vmas% && echo %authd%
echo %charText%
sc query %vmus% && net stop %vmus% && echo %usbarbs% || net start %vmus% && echo %usbarb%
echo %charText%
sc query "%vmns%" && net stop"%vmns%" && echo %nats% || net start"%vmns%" && echo %nat%
echo %charText%
sc query %vmd% && goto exit_this || goto setVMhost
:noService
echo;
echo %vmNoService%
pause >nul
exit:setVMhost
setvmHost="HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc.\VMware Drivers" /v "VMnetuserif.installPath"reg query %vmHost% >nul 2>nul&&echo 检测到VM路径 && goto startExe||echo 未检测到VM安装路径 && goto exit_this
:startExe
setnameExe=vmware.exe
for /f "skip=1 delims=: tokens=1,*" %%i in ('reg query %vmHost%') do (
setstr=%%i
setvar=%%j
set"var=!var:"=!"   if not "!var:~-1!"=="=" set value=!str:~-1!C:!var!)set openExe="%value:~1,-15%%nameExe%"start /min cmd /C %openExe%ping -n 3 127.0.0.1 > nultasklist | find /i "VMware Workstation" && echo 打开路径 %openExe:~1,-1% || echo %openExe:~1,-1% 请手动打开VMWare虚拟机goto exit_this:exit_thisecho;echo %vmOver%for /l %%c in (0 1 12) do ( echo; )pause >nulrem ping -n 7 127.0.0.1 > nultaskkill /F /IM cmd.exeexit

加了好几样懒方法和识别后台服务,但貌似还是会重复启动vm的窗口。

反正难度不大就当改卷子


文本文件改bat格式


image.png

目录
相关文章
|
4月前
|
Unix Linux 虚拟化
Linux介绍和vm17pro安装 和Centos以及vm简单操作
Linux介绍和vm17pro安装 和Centos以及vm简单操作
121 0
|
7月前
|
Java 虚拟化
[Stupidly Simple VM ]SSVM #1配置 & 启动虚拟机
本文主要介绍SSVM框架的配置方法
113 0
|
8月前
|
虚拟化 Windows
VMWare player启动虚拟机出错 - 模块Disk启动失败
VMWare player启动虚拟机出错 - 模块Disk启动失败
282 0
VMWare player启动虚拟机出错 - 模块Disk启动失败
|
弹性计算 PHP Docker
Contain Yourself! The VM Is Evolving
From traditional VMs to Docker containers, learn how the virtualization industry is evolving to meet constantly changing business needs.
2190 0
Contain Yourself! The VM Is Evolving