Bat file for installing .net 3.5 framework for win server 2012

I want to create a bat file to install .net Framework 3.5 on Windows Server 2012. I tried like this, but without success:

cd /D %userprofile% C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Import-Module ServerManager powershell -ImportSystemModules Add-WindowsFeature NET-Framework-Features 

It seems that after logging into the PowerShell console, the last 2 commands are not executed.

Anyone have an idea why stuck?

Or does anyone have another bat file, how to automate the installation of .net 3.5 on a Windows 2012 server?

After several attempts, I made bat, working with the next command when it starts manually.

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

But when I try to run it from dotnetInstaller, then this same bat no longer works

  <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> 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 =  <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> 

I get this error. Any idea why?

The term "Add-WindowsFeature" is not recognized as a cmdlet name, functi on, script, or operating program. Check the spelling of the name or at, make sure that the path is correct and try again. On line: 1 char: 19 + Add-WindowsFeature <<-name net-framework-features + CategoryInfo: ObjectNotFound: (Add-WindowsFeature: String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException

+4
source share
5 answers

I did this with this bat:

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

And in bootstrapper 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> 

It does not seem to have worked before because the bootstrapper started the battle process as 32 bits that PS did not like. So I set disable_wow64_fs_redirection = "True", now it starts the bat as a 64-bit process and works :)

Thanks to everyone for the answer. I sent an answer, maybe it will help someone else.

+1
source

Two options:

1) Use the script file and the File parameter.

 ############# ## script.ps1 Import-Module ServerManager Add-WindowsFeature NET-Framework-Features 

Then do:

 powershell -File c:\script.ps1 

2) Use the Command parameter:

 powershell -Command "Import-Module ServerManager; Add-WindowsFeature NET-Framework-Features" 

In any case, try to avoid switching -ImportSystemModules (deprecated in version 3), it's just overkill. It will load all system modules when you only need the ServerManager module. And if you work in v3, the Import-Module command is also redundant. See Module startup function .

+4
source

This works as follows:

 cd /D %userprofile% C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Import-Module ServerManager; ImportSystemModules Add-WindowsFeature NET-Framework-Features" pause 
0
source

To run commands with powershell, use the -Command parameter, for example:

 powershell.exe -command "&{Import-Module ServerManager; ImportSystemModules Add-WindowsFeature NET-Framework-Features}" 
0
source

Go to the command line and enter the following:

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

Note. The source should be the Windows 2012 installation disc. In my case, it was located on D:

0
source

All Articles