powershell – bat文件为win server 2012安装.net 3.5框架
我想制作一个bat文件来在
Windows Server 2012上安装.net Framework 3.5.
我试过这样但没有成功: cd /D %userprofile% C:WindowsSystem32WindowsPowerShellv1.0powershell.exe Import-Module ServerManager powershell -ImportSystemModules Add-WindowsFeature NET-Framework-Features 似乎在进入powershell控制台后,最后2个命令没有被执行. 有谁知道为什么会卡住? 或者是否有人有其他bat文件如何在Windows Server 2012中自动安装.net 3.5? 经过多次尝试后,我在手动运行时使用以下命令. call C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -ImportSystemModules Add-WindowsFeature NET-Framework-Features 但是,当我尝试从dotnetInstaller运行它同样的蝙蝠不再工作 <component command="CMD.EXE /K "#APPPATHInstall.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="SOFTWAREMicrosoftNET Framework SetupNDPv3.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="SOFTWAREMicrosoftNET Framework SetupNDPv3.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的名称functi 解决方法
两种选择:
1)使用脚本文件和File参数. ############# ## script.ps1 Import-Module ServerManager Add-WindowsFeature NET-Framework-Features 然后执行: powershell -File c:script.ps1 2)使用Command参数: powershell -Command "Import-Module ServerManager; Add-WindowsFeature NET-Framework-Features" 在任何情况下,尽量避免使用-ImportSystemModules开关(在v3中弃用),这只是一种矫枉过正.当您只需要ServerManager模块时,它将加载所有系统模块.如果您在v3中工作,Import-Module命令也是多余的.请参见模块autp-loading feature. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows – 集中远程AD DC?
- group-policy – GPMC缺少隐藏/显示链接
- 文件和注册表
- windows-server-2003 – Windows Server 2003上的TCP拥塞窗
- active-directory – (主要)Windows(AD)环境中的Linux服务器
- windows-server-2003 – 使用CentOS 5.3的虚拟化Windows 20
- Windows – 如何删除Server 2008 SP1的安装文件
- 如何从Windows中的pfx文件中删除CA根证书?
- 在Windows 10上禁用TortoiseSVN中的德语拼写检查程序
- 如何允许域用户在没有本地管理员权限的情况下编写Windows事