刚开始我是因为要启动DevEco Studio虚拟机,这是报错说未启动Hyper-V。
于是我开始上网找资料,查看怎么启动,结果都是家庭版不能直接到“启动或关闭Windows功能"打开。
找的很多资料都是说
在启用或关闭Windows功能找不到Hyper-v节点
Windows10解决方法:
解决办法
1.将下面命令复制到文本文档中,并将文档重命名Hyper.cmd
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
在CMD中开启Hyper-V
与PowerShell方式类似,您也可以使用命令提示符在Win11、10上安装Hyper-V。
步骤1. 在搜索框中输入“cmd”并以管理员身份将其打开。
步骤2. 输入以下命令并按Enter键执行。
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
如何在Win11家庭版中启用Hyper-V?
注意
由于 Windows 家庭版没有 Hyper-V,因此您必须先安装它。如果您有专业版、教育版或企业版,则可以跳过此步骤并继续阅读本文的下一部分。若要检查您拥有的版本,请在“运行命令”框中键入 winver,然后获取操作系统的详细信息。
如果你有 Windows 11 家庭版,请按照以下步骤安装 Hyper-V:
复制以下批处理代码,新建空白文本后保存,保存更改文本 .txt 后缀为 .bat 格式,这样就能变为批处理脚本。右键以管理员身份运行即可。
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
pause
重新启动后,Hyper-V 将在您的 Windows 上安装并自动启用。
但是我运行以上文件一直在报错。
报错如下:
C:\Users\Sweet\Desktop>pushd “C:\Users\Sweet\Desktop\”
文件名、目录名或卷标语法不正确。
C:\Users\Sweet\Desktop>dir /b C:\WINDOWS\servicing\Packages*Hyper-V*.mum 1>hyper-v.txt 找不到文件
C:\Users\Sweet\Desktop>for /F %i in (‘findstr /i . hyper-v.txt 2>nul’) do dism /online /norestart /add-package:“C:\WINDOWS\servicing\Packages%i”
系统找不到文件 ‘findstr。
C:\Users\Sweet\Desktop>del hyper-v.txt C:\Users\Sweet\Desktop>Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
'Dism' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
C:\Users\Sweet\Desktop>pause 请按任意键继续.
解决办法:
(我的建议是直接使用管理员模式打开cmd)
1. C:\Users\Sweet\Desktop>pushd “C:\Users\Sweet\Desktop\”
文件名、目录名或卷标语法不正确。
解决办法:将文件里面所有的符号都改成英文的就可以了。
(解释:如果使用管理员模式打开cmd,pushd “C:\Users\Sweet\Desktop\”这个命令其实不用执行。直接执行第二条命令就可以)
2.C:\Users\Sweet\Desktop>dir /b C:\WINDOWS\servicing\Packages*Hyper-V*.mum 1>hyper-v.txt 找不到文件
解决办法:dir /b C:\WINDOWS\servicing\Packages\*Hyper-V*.mum 1>hyper-v.txt
(解释:在Packages后加一个斜杠)
随后执行:type hyper-v.txt 查看是否有内容 有内容就说明这句话执行下来没问题了
3.C:\Users\Sweet\Desktop>for /F %i in (‘findstr /i . hyper-v.txt 2>nul’) do dism /online /norestart /add-package:“C:\WINDOWS\servicing\Packages%i”
系统找不到文件 ‘findstr。
解决办法:改成for /f %i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%i"即可。
(解释:2后面多一个^)
4.C:\Users\Sweet\Desktop>del hyper-v.txt C:\Users\Sweet\Desktop>Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
'Dism' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
分析:这是因为我这里没有进到C:\Windows\System32\dism.exe中,所以找不到'Dism'
所以应该这样执行:
C:\Windows\System32\dism.exe /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
但是又报错
根据提示执行
C:\Windows\System32\dism.exe /online /Get-Features
得到以下结果:
自己往下好好翻一翻,我这里是翻到了唯一一个跟hype相关的就是。(我的HypervisorPlatform显示在倒数第三行)
因为上面报错是说功能名称 Microsoft-Hyper-V-All 未知。未识别出 Windows 功能名称。
但是我现在能找到的唯一和Hype相关的就叫HypervisorPlatform,所以我就把Microsoft-Hyper-V-All改成HypervisorPlatform就可以了。
(这是我二次操作了,所以这里没有出现需要重启的信息)
一般是会问你是否重启,填Y就可以。
重启后再去启动或关闭Windows功能打开虚拟机平台!!!!!
(我这里是叫虚拟机平台,不知道你们那边会叫啥,看着打开就行)
最后成功在DevEco Studio中开启鸿蒙虚拟机!
前半部分内容来自以下链接。后面部分解决报错是我自己写的。
文章参考:https://blog.csdn.net/qq_73735007/article/details/139504235