5

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 のインストールを自動化する他のバット ファイルを持っている人はいますか?

さらに試した後、手動で実行すると、次のコマンドでバットが動作するようになりました。

call C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ImportSystemModules Add-WindowsFeature NET-Framework-Features

しかし、dotnetInstaller から実行しようとすると、同じバットが機能しなくなりました

 <component command="CMD.EXE /K &quot;#APPPATH\Install.net3.5.bat&quot;" 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」という用語は、コマンドレット、関数、スクリプト ファイル、または操作可能なプログラムの名前として認識されません。名前のスペルを確認するか、ap ath が含まれていた場合は、パスが正しいことを確認してから再試行してください。行:1 文字:19 + Add-WindowsFeature <<<< -name net-framework-features + CategoryInfo : ObjectNotFound: (Add-WindowsFeature:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

4

6 に答える 6

1

私はこのバットでそれを動作させました:

call C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ImportSystemModules Add-WindowsFeature NET-Framework-Features

そして 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>  

PS が気に入らなかった 32 ビットとしてブートストラッパーがバット プロセスを開始していたため、以前は機能しなかったようです。だから私は disable_wow64_fs_redirection="True" を入れて、バットを64ビットプロセスとして実行し、動作します:)

皆さん返信ありがとうございます。私はおそらく他の誰かを助ける答えを投稿しました:)

于 2013-04-08T09:34:03.100 に答える
0

コマンド プロンプトに移動し、次のように入力します。

dism /online /enable-feature /featurename:NetFX3 /all /Source:d:\sources\sxs /LimitAccess

注: ソースは、Windows 2012 インストール ディスクである必要があります。私の場合、これは D: にありました。

于 2013-08-04T22:23:53.200 に答える
0

これは次のように機能します。

cd /D %userprofile% 
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Import-Module ServerManager; ImportSystemModules Add-WindowsFeature NET-Framework-Features"
pause
于 2013-04-05T12:28:47.543 に答える
0

PowerShell でコマンドを実行するには、次のように -Command パラメーターを使用します。

powershell.exe -command "&{Import-Module ServerManager; ImportSystemModules Add-WindowsFeature NET-Framework-Features}"
于 2013-04-05T12:29:44.830 に答える