我想制作一个批处理文件,在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
看起来在进入PowerShell控制台后,最后2个命令未执行。
有人知道为什么会卡住吗?
或者有其他批处理文件可以自动安装Windows Server 2012中的.NET 3.5吗?
经过更多尝试,当手动运行时,我使用以下命令使bat文件工作。
call C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ImportSystemModules Add-WindowsFeature NET-Framework-Features
但是当我尝试从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>
我收到了这个错误,有什么想法吗?
'Add-WindowsFeature' 这个术语不被认为是一个 cmdlet、function、script 文件或可执行程序的名称。请检查拼写,如果包含路径,则验证路径是否正确,然后重试。 在第 1 行第 19 列 + Add-WindowsFeature <<<< -name net-framework-features + CategoryInfo : ObjectNotFound: (Add-WindowsFeature:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException