MgmTest

{REQ}Install .NETFramework 2

28 posts in this topic

hi.
Me Need install .Net 2 In Win XP And Install .Net 3.5 In Win 8&8.1.
plz help me fixed code.
thanks a lot.

@ECHO offclsset DOTNETINSTALLED=NOREG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\v2.0" >NUL && set DOTNETINSTALLED=YESIF %DOTNETINSTALLED%==YES goto MAINgoto PREREQUISITE:PREREQUISITEREM Execute Prerequisite Setup ProgramSTART /wait Dot_NET_2.exe /qping -n 20 127.0.0.1 > NULL:MAINREM Execute Main Setup ProgramSTART /wait test.exe
0

Share this post


Link to post
Share on other sites

Here is another way of checking for .Net Framework is on a computer using VBS scriptingand using WMI query.

Tested this on Windows 7 and it returns the if True message

Example ChkNetFrameWork.vbs

'-> Runtime Objects Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2") '-> Runtime Varibles Dim Net, Obj, Var Net = False'-> Loop Threw Installed Products  For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_Product")'-> Found A Version Of .Net Framework   If Instr(1,Obj.Caption,".net",1) Then     Net = True    Var = Var & Obj.Caption & " - " & Obj.Version & vbCrLf    End if   Next'-> Confirm .Net Framework Installed    If Net = True Then    Act.Popup "A version of .Net Framework was Found" & vbCrLf & _   Var,10,".Net Framework Installed",4128  Else'-> Code Here If .Net Framework Is Not Installed'-> Example Below On How To Use The VBS Object Act To Run A Install'-> Act.Run("Path:\To\The\File.exe /Switches"),1,True  End If 
Rename ChkNetFrameWork.vbs.txt to ChkNetFrameWork.vbs to make active

ChkNetFrameWork.vbs.txt

0

Share this post


Link to post
Share on other sites

The Microsoft recommended registry key method is to check:

Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727 Value: Install, Type: REG_DWORD, Data: 1

0

Share this post


Link to post
Share on other sites

I write exe with c#.
I have this problem that .net framework2 be installed automatically in windows xp and .net farmework 3.5 in windows 8 & windows 8.1. I mean I want my exe recognize what is OS then according OS install appropriate .netfaramework.

0

Share this post


Link to post
Share on other sites

Perhaps this might work

ChkNetFrameWork2.vbs.txt

'-> Runtime Objects Dim Act :Set Act = CreateObject("Wscript.Shell") Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2") '-> Runtime Varibles Dim Net, Obj, Var Net = False'-> Loop Threw Installed Products  For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_Product")'-> Found A Version Of .Net Framework   If Instr(1,Obj.Caption,".net",1) Then     Net = True    Var = Var & Obj.Caption & " - " & Obj.Version & vbCrLf    End if   Next'-> Confirm .Net Framework Installed    If Net = True Then    Act.Popup "A version of .Net Framework was Found" & vbCrLf & _   Var,10,".Net Framework Installed",4128  Else'-> Code Here If .Net Framework Is Not Installed'-> Example Below On How To Use The VBS Object Act To Run A Install'-> Act.Run("Path:\To\The\File.exe /Switches"),1,True     If InStr(1,Os,"Windows 7",1) Then '-> Code Here    ElseIf InStr(1,Os,"Windows Vista",1) Then '-> Code Here   ElseIf InStr(1,Os,"Windows XP",1) Then '-> Code Here   ElseIf InStr(1,Os,"Windows 8",1) Then'-> Code Here   ElseIf InStr(1,Os,"Windows 8.1",1) Then'-> Code Here   End If   End If '-> Function To Get Os  Function Os()   For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_OperatingSystem")    Os=Obj.Caption   Next  End Function
Rename ChkNetFrameWork2.vbs.txt to ChkNetFrameWork2.vbs make active

ChkNetFrameWork2.vbs.txt

Tested this code on my Vista and Win 7 and it return the correct Os, it was the

only way I could test the new code for runtime errors.

Dim Wmi :Set Wmi = GetObject("winmgmts:\\.\root\CIMV2")   If InStr(1,Os,"Windows 7",1) Then '-> Code Here     MsgBox Os   ElseIf InStr(1,Os,"Windows Vista",1) Then    '-> Code Here    MsgBox Os   ElseIf InStr(1,Os,"Windows XP",1) Then '-> Code Here    MsgBox Os   ElseIf InStr(1,Os,"Windows 8",1) Then'-> Code Here    MsgBox Os   ElseIf InStr(1,Os,"Windows 8.1",1) Then'-> Code Here    MsgBox Os   End If '-> Function To Get Os  Function Os()   For Each Obj In Wmi.ExecQuery("SELECT * FROM Win32_OperatingSystem")    Os=Obj.Caption   Next  End Function
0

Share this post


Link to post
Share on other sites

I write exe with c#.

I have this problem that .net framework2 be installed automatically in windows xp and .net farmework 3.5 in windows 8 & windows 8.1. I mean I want my exe recognize what is OS then according OS install appropriate .netfaramework.

You shouldn't need a v3.5 executable, .NET Framework version 3.5 is already included with Windows 8, it is an optional component.

As for detecting the version, have you read this?

0

Share this post


Link to post
Share on other sites

me Chang .net in 4 but need silent install fast .net Fix Code Me :

not install .net

@ECHO offclsFOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\Oasdsd.exe SET CDROM=%%i:SET PP=%cdrom%set DOTNETINSTALLED=NOREG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Policy\v4.0" >NUL && set DOTNETINSTALLED=YESIF %DOTNETINSTALLED%==YES goto MAINgoto PREREQUISITE:PREREQUISITEREM Execute Prerequisite Setup ProgramSTART /wait "%PP%\Microsoft .NET Framework 4.0 32 & 64bit\Setup.exe /q /norestart"ping -n 10 127.0.0.1 > NULL:MAINREM Execute Main Setup ProgramSTART /wait Oasdsd.exe
Edited by MgmTest
0

Share this post


Link to post
Share on other sites

Which pre-requistite are you checking for, the client profile:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client Value: Install, Type: REG_DWORD, Data: 1
or the full version:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full Value: Install, Type: REG_DWORD, Data: 1


Regardless of that fact, AhrimanSefid, and the fact you haven't acknowledged my last post, your script really needs a rewrite.

...try changing the name of your .NET installer directory
From: "Microsoft .NET Framework 4.0 32 & 64bit"
to: "Microsoft .NET Framework 4.0 x86_64"


Then try this:

@ECHO OFFSETLOCALSET "M=Oasdsd.exe"SET "S=Microsoft .NET Framework 4.0 x86_64\Setup.exe"SET "F="SET "N=HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\"SET "_="FOR /F %%A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (IF EXIST "%%A%M%" SET "_=%%A")IF NOT DEFINED _ GOTO :EOFFOR %%A IN (Client Full) Do (    REG QUERY "%N%%%A" /V Install >NUL 2>&1 && SET F=Yes)IF NOT DEFINED F CALL :PRE:MAINIF DEFINED F ("%_%%M%")GOTO :EOF:PREIF EXIST "%_%%S%" (SET B=x%PROCESSOR_ARCHITECTURE:~-2%    IF %B% EQU x86 (IF DEFINED PROCESSOR_ARCHITEW6432 SET B=x64)    START "" /WAIT "%_%%S%" /%B% /q /norestart && (SET F=Yes))

You'll have to decide for yourself if you require the START "" /WAIT in the bottom line!

0

Share this post


Link to post
Share on other sites

I've already posted a similar reply here, and read it, but for some reason it doesn't exist anymore!

The message posted by ricktendo64 in that other place is most certainly not a solution. It doesn't use the OP's file, installs a different executable and version of .NET framework and doesn't make any attempt to check for the 'prerequisite' existence first.

0

Share this post


Link to post
Share on other sites

Thanks but me not need check 86&64.

and remove line PRE not install .net.

"Microsoft .NET Framework 4.0\Setup.exe"

Which pre-requistite are you checking for, the client profile:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client Value: Install, Type: REG_DWORD, Data: 1
or the full version:
Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full Value: Install, Type: REG_DWORD, Data: 1


Regardless of that fact, AhrimanSefid, and the fact you haven't acknowledged my last post, your script really needs a rewrite.

...try changing the name of your .NET installer directory
From: "Microsoft .NET Framework 4.0 32 & 64bit"
to: "Microsoft .NET Framework 4.0 x86_64"


Then try this:

@ECHO OFFSETLOCALSET "M=Oasdsd.exe"SET "S=Microsoft .NET Framework 4.0 x86_64\Setup.exe"SET "F="SET "N=HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\"SET "_="FOR /F %%A IN ('MOUNTVOL^|FINDSTR [C-Z]:\\') DO (IF EXIST "%%A%M%" SET "_=%%A")IF NOT DEFINED _ GOTO :EOFFOR %%A IN (Client Full) Do (    REG QUERY "%N%%%A" /V Install >NUL 2>&1 && SET F=Yes)IF NOT DEFINED F CALL :PRE:MAINIF DEFINED F ("%_%%M%")GOTO :EOF:PREIF EXIST "%_%%S%" (SET B=x%PROCESSOR_ARCHITECTURE:~-2%    IF %B% EQU x86 (IF DEFINED PROCESSOR_ARCHITEW6432 SET B=x64)    START "" /WAIT "%_%%S%" /%B% /q /norestart && (SET F=Yes))

You'll have to decide for yourself if you require the START "" /WAIT in the bottom line!

Edited by MgmTest
0

Share this post


Link to post
Share on other sites

@MgmTest, once you get a solution that works for you, if you would please post the complete solution here for the benefit of others who might need to do a similar thing we would very much appreciate it.

Cheers and Regarads

0

Share this post


Link to post
Share on other sites

Your original requirement told us you were using .NET for x86 and x64, because you appeared to be using a file named setup.exe, my assumption is that you have extracted the files from the official installer. No longer using the official installer means that you would need to be able to provide a switch to the setup routine depending upon the architecture of the host OS, I've done that for you.. If you do not need to check for architecture, learn to provide better information in your requests in future then change the bottom four lines to read:

:PREIF EXIST "%_%%S%" (START "" /WAIT "%_%%S%" /q /norestart && (SET F=Yes))

Also if you are having difficulty with something, please make a better attempt at explaining the specifics.
perhaps remove the echo from the script, capture the output and post it here!

0

Share this post


Link to post
Share on other sites

Remove x86_64

SET "S=\Microsoft .NET Framework 4.0\Setup.exe"

1394887538391.png

Edited by MgmTest
0

Share this post


Link to post
Share on other sites

Please post the COMPLETE code for "run", and that of any routines that "run" calls, if appropriate, if you would like our further help.

Cheers and Regards

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.