Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 574 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bat file to install .net 3.5 framework for win server 2012

#1
I want to make a bat file to install .net Framework 3.5 on Windows Server 2012.
I tried like this but with no success:

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

Seems that after entering powershell console last 2 commands are not executed.

Does anyone have an idea why is getting stuck?

Or does anyone have other bat file how to automate install of .net 3.5 in windows server 2012?

After more trying i made the bat working with the following command when is run manually.

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

But when i try run it from dotnetInstaller same bat is not working anymore

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

I get this error Any idea why?

The term 'Add-WindowsFeature' is not recognized as the name of a cmdlet, functi
on, script file, or operable program. Check the spelling of the name, or if a p
ath was included, verify that the path is correct and try again.
At line:1 char:19
+ Add-WindowsFeature <<<< -name net-framework-features
+ CategoryInfo : ObjectNotFound: (Add-WindowsFeature:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Reply

#2
This works the following way:

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

#3
To run commands with powershell use the -Command parameter, like so:

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

#4
Two options:

1) Use a script file and the File parameter.

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

Then execute:

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 the -ImportSystemModules switch (deprecated in v3), it's just an overkill. It will load all system modules when all you need is just the ServerManager module. And if you are working in v3, the Import-Module command is redundant as well. See the module [autp-loading feature][1].


[1]:

[To see links please register here]

Reply

#5
I made it work with this bat:

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

And in dotnetInstaller bootstrapper:

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

Seems that it didn't work before because the bootstrapper was starting the bat process as 32 bits which PS didn't like. So i put disable_wow64_fs_redirection="True" now it runs the bat as 64 bits process and it works :)

Thank you all for reply.
I posted the answer maybe will help someone else :)
Reply

#6
Go to a command prompt and enter this:

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

Note: Source should be the Windows 2012 installation disc. In my case, this was located on D:
Reply

#7
You could also use [chocolatey][1]:

choco install dotnet3.5


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through