注:以下内容仅为本人成功经验,电脑小白请三思而后行,操作不当可能导致文件丢失、无法进入系统等后果。请做好备份工作。
本文环境
在本人两台电脑下测试均成功,使用的在线账户登录
Windows 11 专业版 22H2 22621.1413
Windows 11 专业版 Insider Preview 22H2 25309.1000
正文
温馨提示:因操作涉及到电脑重启,请用别的设备打开本文后再进行接下来的操作。
1.修改注册表
1.Win+R
快捷键打开 regedit
2.依次进入:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
3.双击ProfileImagePath
修改为你的新用户名
2.重启进入临时账户
直接重启,输入密码登录;此时会因为找不到你的账户,系统会卡住转圈很久,耐心等待进入系统后会提示你是否注销,直接关闭弹窗进行下面步骤。

3.修改文件夹名
按照路径进入后,将文件夹修改为你的新用户名

如果遇到文件夹正在使用的提示
请尝试按 Win + S 键搜索 “资源监视器” 并打开;点击窗口上的 CPU 标签;点击 “关联的句柄” 右侧的搜索框输入 C:\Users\izumi
(记得改为你自己的路径)
接着在下面的搜索结果列表中,会看到正在使用该文件夹的程序;然后全选右键选择结束进程后再执行重命名操作。

4.创建新旧文件夹之间的链接
1.按图中路径找到并以管理员身份运行cmd.exe

2.输入mklink /j C:\Users\pyrde C:\Users\izumi
运行,前面路径是你的旧用户名,后面是新用户名。


5.修改用户名
接着输入control userpasswords2
,找到当前用户点击属性,然后修改用户名保存,重启电脑;此时基本就算修改完成了。

后记
1.小问题
因为我们是通过建立的链接来使得访问旧路径的程序也能正常访问到新文件夹的内容,所以其实并不完美,比如OneDrive他还是显示指向原来的路径(我们在正文第4步进行了链接操作,所以程序本身是能正常使用的)

当然我们可以在OneDrive设置中先取消链接,再重新添加,就可以更改为新用户名的位置。


所以理论上我们可以不执行正文第4步,当遇到软件无法正常运行时再手动修改路径or环境变量。

2.没敢尝试的办法
网上有通过搜索注册表将旧用户名批量替换为新用户名的操作,但我没敢尝试,有兴趣的可以自己试试。