关于程序员修改电脑用户名中文为字母那些事

公司新弄得电脑是中文用户名和路径的,我当时也一直用,现在发现各种问题,开始后悔,但是不想换用户名不想重装系统,只能想办法了

使用Registry Workshop


image.png

然后改用户名


image.png

https://answers.microsoft.com/en-us/windows/forum/all/how-to-change-the-username-and-username-folder-in/69ea633b-7f74-47e3-9130-ab8b5aa3ad4b?page=2

https://blog.csdn.net/qq_34146694/article/details/117446830

https://blog.csdn.net/qq1337715208/article/details/104600204?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-1-104600204-blog-117446830.pc_relevant_multi_platform_whitelistv3&spm=1001.2101.3001.4242.2&utm_relevant_index=4
刚开始我是只改了微软里面提供的答案的方法,[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]结果没啥用,后面直接导出真个注册表然后用开发工具批量替换重新倒回去,但是提示很多失败,而且还是有部分漏网之鱼所以找到了更多的办法

写脚本批量替换 和工具


#设置注册表并日志
function SetAndLong($Path,$Name,$Value,$OldValue){
    #Requires -RunAsAdministrator
    $command="Set-ItemProperty -Path $Path -Name $Name -Value $Value "+';$?'
    $status=iex $command
    if ($status){
        "$(Get-Date) $command oldvalue $OldValue" |Out-File -Append -Encoding $(if ($PSVersionTable.PSVersion.Major -ge 6){"utf8NoBOM"}else{"utf8"}) -FilePath "regchange.log"
    }

}

#替换注册表https://stackoverflow.com/questions/26680410/powershell-find-and-replace-on-registry-values#
function RegistryValue-Replace(
  [string]$path = $(throw "path为必填(即注册表路径)"),
  [string]$NewValue = $(throw "NewValue为必填(即替换的值)"),
  [string]$key, #可选为指定键
  [string]$OldValue, #OldValue可选(即当前值),有则进行校验
  [ScriptBlock]$DoMethod #DoMethod可选,自定义处理函数
  ){
    Get-Item -ErrorAction SilentlyContinue -path  "Microsoft.PowerShell.Core\Registry::$path"|
    foreach {
        Get-ItemProperty -Path "Microsoft.PowerShell.Core\Registry::$_" | 
        foreach {
            $CurrentUserShellFoldersPath = $_.PSPath
            $_.PSObject.Properties |
            foreach {
                if (![String]::IsNullOrEmpty($key) -and !($_.name -like $key) ){ #键校验
                    return
                }
                if (![String]::IsNullOrEmpty($OldValue) -and !($_.Value -eq $OldValue)){ #旧值校验
                    return
                }
                if ($DoMethod -ne $Null){
                    $DoMethod.invoke($_,$CurrentUserShellFoldersPath)
                    return
                }
                SetAndLong -Path $CurrentUserShellFoldersPath -Name $_.Name -Value $newValue -OldValue $_.Value
            }
        }
    }
}





# 脚本用于扫描替换注册表值,比如修改用户文件夹名后
Import-Module .\regedit.psm1 #引入脚本
$replaceKey=@('C:\Users\别往','C:\Users\biewang') #C:\Users\别往 替换为 C:\Users\biewang
# check param num
if ($replaceKey.count -ne 2)
{
    throw "参数不匹配,replaceKey需要两个参数"
}
$re=$replaceKey[0] -replace "\\","\\"
# query regdata
function Shell-Do(){
    #遍历注册表5个根项
    Foreach($hkey in @('HKCR','HKCU','HKLM','HKU','HKCC')) {
        $querydata=reg query $hkey /s /d /f $replaceKey[0] #HKCR HKCU HKLM HKU HKCC
        [regex]::matches($querydata,'(?m)(?\S+) {5}\S+ {4}\S+ {4}') |
        foreach{
            RegistryValue-Replace $_.Groups['path'].value $null -DoMethod {
                param($Propert,[string]$path)
                if ($Propert.Value -match $re){
                    $new=$Propert.Value -replace $re,$replaceKey[1]
                    SetAndLong -Path "'$path'" -Name "`"$($Propert.Name)`"" -Value "'$new'" -OldValue "$($Propert.Value)"
                }
            }
        }
    }
}

Shell-Do
————————————————
版权声明:本文为CSDN博主「若不能同行_那么祝你一路顺风」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_34146694/article/details/117446830

但是我遇到了一个棘手的问题

image.png

部分无法替换的目前只能就此作罢
这可能需要进入u盘系统进行操作了

最后附上匹配的但是无法修改的特征

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\DRIVERS\DriverDatabase\DriverPackages\tap0901.inf_amd64_5a1fec2fbbccefcc]
"OemPath"="c:\\users\\惠普\\appdata\\local\\temp"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{9503F8DC-612F-4000-8EAE-7C328BE643B6}]
"Path"="\\WpsUpdateTask_惠普"
"Author"="惠普"
"URI"="\\WpsUpdateTask_惠普"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\WpsUpdateTask_惠普]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules\14]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\AppData\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules\15]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\MicrosoftEdgeBackups\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules\16]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\.*\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\1]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\source\\repos\\CoreWebApi_\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\15]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\AppData\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\16]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\MicrosoftEdgeBackups\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\17]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\.*\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\15]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\source\\repos\\CoreWebApi_\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\28]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\AppData\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\29]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\MicrosoftEdgeBackups\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\30]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\.*\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\StateRepository\Cache\PackageExternalLocation\Data\5]
"Path"="C:\\Users\\惠普\\AppData\\Local\\Microsoft\\OneDrive\\22.146.0710.0001"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders]
"C:\\Users\\惠普\\AppData\\Roaming\\Microsoft\\Installer\\"=""
"C:\\Users\\惠普\\AppData\\Roaming\\Microsoft\\Installer\\{4E90D13D-B9D5-4130-9AC3-B2F67945E59D}\\"=""
"C:\\Users\\惠普\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\blender\\"=""
"C:\\Users\\惠普\\AppData\\Roaming\\Microsoft\\Installer\\{0E652E96-766B-41AF-A168-768D5F2BBE46}\\"=""
"C:\\Users\\惠普\\AppData\\Roaming\\npm\\"="1"
"C:\\Users\\惠普\\AppData\\Local\\Autodesk\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\default_NC\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\"="1"
"C:\\Users\\惠普\\Autodesk\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\default_NC\\css\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\default_NC\\fonts\\"="1"
"C:\\Users\\惠普\\AppData\\Local\\Autodesk\\Genuine Autodesk Service\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\default_NC\\img\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\default_NC\\js\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\locales\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\UPI\\"="1"
"C:\\Users\\惠普\\Autodesk\\Genuine Service\\default_NC\\win\\"="1"
"C:\\Users\\惠普\\AppData\\Roaming\\Microsoft\\Installer\\{C21A2088-38CA-48FB-9707-1FC8AAC66FA9}\\"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\360Safe\safemon]
"clientlogpath"="C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\LogInfo"
"OpenUrlExe"="C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\0pehM\\f011620d.exe;C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\UrlMgr

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\360Safe\safemon]
"clientlogpath"="C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\LogInfo"
"OpenUrlExe"="C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\0pehM\\f011620d.exe;C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\UrlMgr\\f011620d.exe;C:\\Users\\惠普\\AppData\\Roaming\\360Safe\\0pehM\\f011620d.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\360Safe\softmgr\epin\baeb33783077a7dfa86a62bf99f0c3f3]
"path"="C:\\Users\\惠普\\AppData\\Local\\Kingsoft\\WPS Office\\11.1.0.12598\\office6\\kwpsshellext64.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\360Safe\softmgr\epin\cc7dcb34517505138cf8dd262fe44d88]
"path"="C:\\Users\\惠普\\AppData\\Local\\Kingsoft\\WPS Office\\11.1.0.12598\\office6\\qingshellext64.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\360Safe\softmgr\epin\fb7ad7ce4aea893168caf3db7e61b724]
"path"="C:\\Users\\惠普\\AppData\\Local\\Kingsoft\\WPS Office\\11.1.0.12598\\office6\\qingnse64.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\360Safe\softmgr\HideDesktopIcons(HKCU)]
"{7AE6DE87-C956-4B40-9C89-3D166C9841D3}"="C:\\Users\\惠普\\AppData\\Local\\Kingsoft\\WPS Office\\11.1.0.12598\\office6\\qingnse64.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules\14]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\AppData\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules\15]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\MicrosoftEdgeBackups\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules\16]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\.*\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\1]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\source\\repos\\CoreWebApi_\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\15]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\AppData\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\16]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\MicrosoftEdgeBackups\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules\17]
"URL"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\.*\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\15]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\source\\repos\\CoreWebApi_\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\28]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\AppData\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\29]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\MicrosoftEdgeBackups\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths\30]
"Path"="file:///C:\\[b20116d4-cde3-4a59-8926-afe3a7cc8561]\\Users\\惠普\\.*\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\Windows Error Reporting\RuntimeExceptionHelperModules]
"C:\\Users\\惠普\\AppData\\Local\\Temp\\wps\\~3bdc47\\CONTROL\\office6\\werhandler.dll"=dword:00000000
"C:\\Users\\惠普\\AppData\\Local\\Kingsoft\\WPS Office\\11.1.0.11875\\office6\\werhandler.dll"=dword:00000000

Cannot import file.reg: Not all data was successfully written to the registry. Some keys are open by the system or other processes, or you have insufficient privileges to perform this operation

解决方法有很多
右键授予权限
安全模式下导入
3、执行cmd /k reg add "HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\New" /ve /t REG_SZ /d {D969A300-E7FF-11d0-A93B-00A0C90F2719} /f

登录和管理员并尝试
启动到安全模式并尝试
完全控制注册表项
使用 ReqOwnIt
使用注册商注册管理器。

我建议你按照下面的方法,看看它是否工作正常:
https://answers.microsoft.com/en-us/windows/forum/all/cannot-import-registry-file-getting-error-cannot/1bd7f5fd-e37e-e011-9b4b-68b599b31bf5
方法一

如何在注册表中授予权限

a) 点击开始

b) 在搜索框中键入 regedit

c) 转到编辑和权限

d) 单击“高级”选项卡并选择“权限”

e) 在权限窗口中选择 用户/组或点击“添加”添加其他用户或组。

f) 在Permission下,勾选“ Allow ”栏下的“Full Control”,分配完全访问权限控制权限。

g) 单击 确定使更改生效,然后单击 确定退出属性窗口

获得注册表的所有权。

a) 点击开始

b) 在搜索框中键入 regedit

c) 转到编辑和权限

d) 单击高级选项卡并选择所有者

e) 如果用户或组不在给定列表中,单击 编辑按钮并 从给定的 更改所有者中选择用户以列出。

f) 您也可以通过添加每个人来授予完全访问权限。

g) 点击 Other users or groups,在提供的字段中输入 Everyone并点击ok。

h) 现在选择 用户/组并单击应用和 确定。如果所选文件夹中有文件和文件夹,请选中“替换子容器和对象的所有者”。
最后我是来劝退的,因为最后出现了这种无法挽救的问题,导致该用户无法登录了,甚至无法删除,最后我不得不用管理员账号了 其实也没啥问题,我直接启用超级管理员
改密码
net user L xxx
添加用户
net user L /add
删除用户
net user L /delete
激活管理员

net user Administrator /active:yes
添加用户到超级管理员组
net localgroup Administrators /add

image.png

你可能感兴趣的:(关于程序员修改电脑用户名中文为字母那些事)