Comments (18)
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 “远程桌面”"
from windows.
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
from windows.
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.
from windows.
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.
from windows.
Agreed that. It'll be easy to keep it in english at default for this project.
For those who use other language, and maybe tired changing the language and wondering why these 3 things not enabled, this script helps out.
And this works for zh-cn locale
hope for it works for all locale.
from windows.
还有一个问题,当使用默认的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 专业版。
from windows.
@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?
from windows.
@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?为什么不使用默认的英文 ISO 并在安装后从 Windows 控制面板更改语言,而不是使用中文 ISO?
主要是想要试一下其它的操作系统,是系统有什么问题吗?
from windows.
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 “远程桌面”"
我做了尝试,并没有效果还会有中文乱码的情况出现
from windows.
@xsy420 Maybe your script can also patch the translations for enabling RDP and Network Discovery ?
from windows.
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.
Or just mark it as an example i18n patch file for those who use another language.
from windows.
@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.
from windows.
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
from windows.
@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?
from windows.
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.它有效!!而且您不必担心更改文件编码。
感谢,您这个方法非常有效!
from windows.
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)
To enable Network Discovery and the FPS, it's easy to change CommandLine
tag.
To enable RDP, and able to support multi language, I add a new SynchronousCommand
tag. And it duplicates the content in FirewallGroup
tag. So I deleted the whole in the parent component
tag. RDP still auto enabled in en-us and zh-cn locale. Will that be okay?
How many xml files should I commit? All of them?
from windows.
Yes please!
from windows.
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.
from windows.
Related Issues (20)
- [Feature]: Request for adding the feature of customizing the MAC address of the virtual machine HOT 2
- [Solved] Can not share host folder with Windows container HOT 7
- Container do not start after reboot HOT 1
- Cannot open and connect from macOS.
- [Question]: Windows Networks Prompt HOT 1
- Custom ISO HOT 1
- [Question]: windows.3788177408.iso (containing windows.base inside) windows.rom windows.vars ? Help me :) HOT 1
- [Question]: use a vhdx into docker container HOT 10
- Always stuck on page "Setup is starting"
- Error when installing Windows
- [Question]: USB Passthrough Multiple Devices with the same Vendor & Product ID
- [Question]: Working with Apache Guacamole
- [Question]: RAM_SIZE less than 1GB HOT 1
- [Question]: Is it possible to set environemnt variables IN WINDOWS directly from docker compose? HOT 2
- setting a costum resolution not working
- Cannot access shared folder using samba
- Start up Error, RAM error
- [Feature]: Adding `QEMU Guest Agent` to Unattend XML
- Docker Compose NOT Using Existing Volume for Windows 10 Container
- Installation failing because of "KVM acceleration not available"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from windows.