Adr*_*rya 5 powershell batch-file .net-3.5 dotnetinstaller windows-server-2012
我想制作一个bat文件来在Windows Server 2012上安装.net Framework 3.5。我尝试这样做但没有成功:
cd /D %userprofile%
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Import-Module ServerManager
powershell -ImportSystemModules Add-WindowsFeature NET-Framework-Features
Run Code Online (Sandbox Code Playgroud)
似乎进入 powershell 控制台后最后 2 个命令没有执行。
有谁知道为什么会卡住?
或者是否有人有其他 bat 文件如何在 Windows Server 2012 中自动安装 .net 3.5?
经过更多尝试后,我让蝙蝠在手动运行时使用以下命令。
call C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ImportSystemModules Add-WindowsFeature NET-Framework-Features
Run Code Online (Sandbox Code Playgroud)
但是当我尝试从 dotnetInstaller 运行它时,同一个蝙蝠不再工作
<component command="CMD.EXE /K "#APPPATH\Install.net3.5.bat"" command_silent="" command_basic="" uninstall_command="" uninstall_command_silent="" uninstall_command_basic="" returncodes_success="" returncodes_reboot="" disable_wow64_fs_redirection="False" id=".Net 3.5 SP1 Win8Server" display_name=".Net 3.5 SP1" uninstall_display_name="" os_filter="" os_filter_min="winServer2008R2" os_filter_max="" os_filter_lcid="" type="cmd" installcompletemessage="" uninstallcompletemessage="" mustreboot="False" reboot_required="" must_reboot_required="False" failed_exec_command_continue="" allow_continue_on_error="True" default_continue_on_error="False" required_install="True" required_uninstall="True" selected_install="True" selected_uninstall="True" note="" processor_architecture_filter="" status_installed="" status_notinstalled="" supports_install="True" supports_uninstall="False" show_progress_dialog="True" show_cab_dialog="True">
<installedcheck path="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" fieldname="Install" fieldvalue="1" defaultvalue="False" fieldtype="REG_DWORD" comparison="match" rootkey="HKEY_LOCAL_MACHINE" wowoption="NONE" type="check_registry_value" description="Installed Check" />
<installedcheck path="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" fieldname="SP" fieldvalue="1" defaultvalue="False" fieldtype="REG_DWORD" comparison="match" rootkey="HKEY_LOCAL_MACHINE" wowoption="NONE" type="check_registry_value" description="Installed Check" />
</component>
Run Code Online (Sandbox Code Playgroud)
我收到此错误知道为什么吗?
术语“Add-WindowsFeature”不被识别为 cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含 ap ath,请验证路径是否正确,然后重试。在第 1 行:19 + Add-WindowsFeature <<<< -name net-framework-features + CategoryInfo : ObjectNotFound: (Add-WindowsFeature:String) [], CommandNotFoundException + ExcellentQualifiedErrorId : CommandNotFoundException
我用这个蝙蝠让它工作:
call C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ImportSystemModules Add-WindowsFeature NET-Framework-Features
Run Code Online (Sandbox Code Playgroud)
在 dotnetInstaller 引导程序中:
<component command="Install.net3.5.bat" command_silent="" command_basic="" uninstall_command="" uninstall_command_silent="" uninstall_command_basic="" returncodes_success="" returncodes_reboot="" disable_wow64_fs_redirection="True" id=".Net 3.5 SP1 Win8Server" display_name=".Net 3.5 SP1" uninstall_display_name="" os_filter="" os_filter_min="winServer2008R2" os_filter_max="" os_filter_lcid="" type="cmd" installcompletemessage="" uninstallcompletemessage="" mustreboot="False" reboot_required="" must_reboot_required="False" failed_exec_command_continue="" allow_continue_on_error="True" default_continue_on_error="False" required_install="True" required_uninstall="True" selected_install="True" selected_uninstall="True" note="" processor_architecture_filter="" status_installed="" status_notinstalled="" supports_install="True" supports_uninstall="False" show_progress_dialog="True" show_cab_dialog="True">
<installedcheck path="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" fieldname="Install" fieldvalue="1" defaultvalue="False" fieldtype="REG_DWORD" comparison="match" rootkey="HKEY_LOCAL_MACHINE" wowoption="NONE" type="check_registry_value" description="Installed Check" />
<installedcheck path="SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" fieldname="SP" fieldvalue="1" defaultvalue="False" fieldtype="REG_DWORD" comparison="match" rootkey="HKEY_LOCAL_MACHINE" wowoption="NONE" type="check_registry_value" description="Installed Check" />
</component>
Run Code Online (Sandbox Code Playgroud)
似乎它以前不起作用,因为引导程序以 32 位启动 bat 进程,而 PS 不喜欢这一点。所以我把disable_wow64_fs_redirection =“True”现在它作为64位进程运行bat并且它可以工作:)
谢谢大家的回复。我发布的答案也许会帮助其他人:)
归档时间: |
|
查看次数: |
12085 次 |
最近记录: |