-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: 修改windos密码 和 使用自定义的镜像无法使用rdp远程 #490
Comments
还有一个问题,当使用默认的iso时是英文的系统,可以正常使用rdp通过docker用户远程。我需要使用中文的系统,但是使用的中文系统+自动安装后无法rdp远程,提示是连接失败。这里使用的iso是https://file.cnxiaobai.com/Windows/%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E5%8C%85/Windows%2011/中的win11 专业版。 |
@zhangchi6414 Why not use the default English ISO and change the language AFTER installation from the Windows Control Panel instead of using a Chinese ISO? |
try add this lot in install.bat powershell -ExecutionPolicy ByPass -Command "Set-NetFirewallRule -DisplayGroup “网络发现” -Enabled True -Profile Any"
powershell -ExecutionPolicy ByPass -Command "Enable-NetFirewallRule -DisplayGroup “文件和打印机共享”"
powershell -ExecutionPolicy ByPass -Command "Enable-NetFirewallRule -DisplayGroup “远程桌面”" |
主要是想要试一下其它的操作系统,是系统有什么问题吗? |
我做了尝试,并没有效果还会有中文乱码的情况出现 |
make sure your install.bat is in GBK encoding and endswith \r\n iconv -f UTF-8 -t GBK src/install.bat target/install.bat
unix2dos target/install.bat |
If you or others want to try custom.iso in another language for installing and remote desktop auto enabled, translations of "Remote Desktop" will be needed. So as translations of "Network Discovery" and "File and Printer Sharing" for enabling those. Currently I only found these three maybe need to be translated. With these months following this project, the xml files changed very often. To stay up to date, I wrote a python script for patching xml files. from lxml import etree
import sys
def read_tag(_):
return str(_.tag).replace('{urn:schemas-microsoft-com:unattend}', '')
def log(_tag):
print(f'patched {_tag}')
def rewrite_xml(_root):
for child in _root:
real_tag = read_tag(child)
###
### start change your Locale if you want when installing
###
# find your needed locale from https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825682(v=win.10)
if real_tag in ['UILanguage', 'SystemLocale', 'UserLocale']:
child.text = 'zh-CN'
log(real_tag)
elif real_tag == 'InputLocale':
child.text = '0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411F-A5AC-CA038EC515D7}'
log(real_tag)
###
### end change your Locale
###
###
### start change your Username and Password if you want when installing
###
elif real_tag == 'LocalAccount':
if read_tag(child[0]) == 'Name':
child[0].text = 'custom-username-placeholder'
log(read_tag(child[0]))
if read_tag(child[2]) == 'Password' and read_tag(child[2][0]) == 'Value':
child[2][0].text = 'custom-password-placeholder'
log(read_tag(child[2]))
elif real_tag == 'AutoLogon':
if read_tag(child[0]) == 'Username':
child[0].text = 'custom-username-placeholder'
log(read_tag(child[0]))
if read_tag(child[3]) == 'Password' and read_tag(child[3][0]) == 'Value':
child[3][0].text = 'custom-password-holder'
log(read_tag(child[3]))
###
### end change your Username and Password
###
else:
rewrite_xml(child)
if __name__ == '__main__':
origin_xml = sys.argv[1]
new_xml = sys.argv[2]
tree = etree.parse(origin_xml)
root = tree.getroot()
rewrite_xml(root)
new_tree = etree.ElementTree(root)
new_tree.write(new_xml) With this script patched, you will get a custom xml file with your password in it. maybe you won't forget password. |
@xsy420 Maybe your script can also patch the translations for enabling RDP and Network Discovery ? |
Good advice. When I wrote this script, I haven't realized that translation is the problem. Now this script can do it. from lxml import etree
import sys
CustomUsername = "custom-username-placeholder"
CustomPassword = "custom-password-placeholder"
RemoteDesktopEnglish = "RemoteDesktop"
NetworkDiscoveryEnglish = "Network Discovery"
FileAndPrinterSharingEnglish = "File and Printer Sharing"
###
### Replace the translations
###
RemoteDesktopTranslation = "远程桌面"
NetworkDiscoveryTranslation = "网络发现"
FileAndPrinterSharingTranslation = "文件和打印机共享"
def read_tag(_):
return str(_.tag).replace('{urn:schemas-microsoft-com:unattend}', '')
def log(_tag):
print(f'patched {_tag}')
def rewrite_xml(_root):
for child in _root:
real_tag = read_tag(child)
###
### start change your Locale if you want when installing
###
# find your needed locale from https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825682(v=win.10)
if real_tag in ['UILanguage', 'SystemLocale', 'UserLocale']:
child.text = 'zh-CN'
log(real_tag)
elif real_tag == 'InputLocale':
child.text = '0804:{81D4E9C9-1D3B-41BC-9E6C-4B40BF79E35E}{FA550B04-5AD7-411F-A5AC-CA038EC515D7}'
log(real_tag)
###
### end change your Locale
###
###
### start change your Username and Password if you want when installing
###
elif real_tag == 'LocalAccount':
if read_tag(child[0]) == 'Name':
child[0].text = CustomUsername
log(read_tag(child[0]))
if read_tag(child[2]) == 'Password' and read_tag(child[2][0]) == 'Value':
child[2][0].text = CustomPassword
log(read_tag(child[2]))
elif real_tag == 'AutoLogon':
if read_tag(child[0]) == 'Username':
child[0].text = CustomUsername
log(read_tag(child[0]))
if read_tag(child[3]) == 'Password' and read_tag(child[3][0]) == 'Value':
child[3][0].text = CustomPassword
log(read_tag(child[3]))
###
### end change your Username and Password
###
###
### start change three translations if you want when installing
###
elif real_tag == 'FirewallGroup':
if RemoteDesktopEnglish in child.attrib.values():
for _ in child:
if read_tag(_) == 'Group':
_.text = RemoteDesktopTranslation
log(RemoteDesktopEnglish)
elif real_tag == 'FirstLogonCommands':
for _ in child:
if _[2].text == 'Enable Network Discovery':
_[1].text = _[1].text.replace(NetworkDiscoveryEnglish, NetworkDiscoveryTranslation)
log(NetworkDiscoveryEnglish)
if _[2].text == 'Enable File Sharing':
_[1].text = _[1].text.replace(FileAndPrinterSharingEnglish, FileAndPrinterSharingTranslation)
log(FileAndPrinterSharingEnglish)
###
### end change three translations if you want when installing
###
else:
rewrite_xml(child)
if __name__ == '__main__':
origin_xml = sys.argv[1]
new_xml = sys.argv[2]
tree = etree.parse(origin_xml)
root = tree.getroot()
rewrite_xml(root)
new_tree = etree.ElementTree(root)
new_tree.write(new_xml) It works!!! And you won't worry about changing file encodings. |
With this script improved and i18n of the three (maybe more needed to be translated later) collected, multi language can be supported automatically. Just with environment like: environment:
UserLocale: "zh-cn" # auto patch locale settings and i18n before using xml to install But it will need python environment in docker image. Or pre-compile script into binary file. |
@xsy420 Yes I was thinking about that also.. but its a lot of work because I need to have the corrects translations that Windows uses for these RDP/Network strings in all possible languages. It would be better if I can change these firewall settings in another way that doesnt require to know their localized name. Another problem is that a lot of the ISO's (especially for versions below Windows 8) are not multi-langual, so I will need to add a lot of extra download mirrors for each possible language. All in all it will be a lot of effort to make sure it works for every Windows version. While the alternative (user just installs the English version and changes the language AFTER installation in the Windows Control Panel) is almost no work for the user and no work for me. |
And in my case Enable-NetFirewallRule -DisplayGroup @(Get-NetFirewallRule | Where-Object Name -Match "NetDIS.*" | Select-Object DisplayGroup -Unique | % DisplayGroup)
Enable-NetFirewallRule -DisplayGroup @(Get-NetFirewallRule | Where-Object Name -Match "FPS-*" | Select-Object DisplayGroup -Unique | % DisplayGroup) can enable network discovery and the FPS |
@xsy420 Yes that would be a great solution if we can just modify the commands in the .XML file so that the same .XML works for both English and Chinese. Can you please test if this works for both languages and then submit it as a pull-request? |
感谢,您这个方法非常有效! |
Yeah. It works fine. I've tested win10 and win11 version, both english and chinese iso.(using VERSION: "win10" and VERSION: "win11" in compose.yml to get english iso. using pre-downloaded chinese simplified win10 and win11 iso and volumn as custom.iso) |
Yes please! |
I now released a new image (v3.07) which has multi-language support and can download Chinese versions. If you set for example: environment:
REGION: "zh-HK"
KEYBOARD: "zh-HK"
LANGUAGE: "Chinese" it will automaticly download the Chinese Windows and apply the keyboard config, etc. |
Is your question not already answered in the FAQ?
Is this a general question and not a technical issue?
Question
当windows设置了用户密码又忘记之后,怎么实现从外部修改密码?就像一些云主机一样可以直接在页面修改系统密码。
The text was updated successfully, but these errors were encountered: