MgmTest Posted March 4, 2014 Share Posted March 4, 2014 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 Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 4, 2014 Share Posted March 4, 2014 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 messageExample 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 activeChkNetFrameWork.vbs.txt Link to comment Share on other sites More sharing options...
Yzöwl Posted March 4, 2014 Share Posted March 4, 2014 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 Link to comment Share on other sites More sharing options...
MgmTest Posted March 5, 2014 Author Share Posted March 5, 2014 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. Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 5, 2014 Share Posted March 5, 2014 Perhaps this might workChkNetFrameWork2.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 FunctionRename ChkNetFrameWork2.vbs.txt to ChkNetFrameWork2.vbs make activeChkNetFrameWork2.vbs.txtTested this code on my Vista and Win 7 and it return the correct Os, it was theonly 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 Link to comment Share on other sites More sharing options...
Yzöwl Posted March 5, 2014 Share Posted March 5, 2014 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? Link to comment Share on other sites More sharing options...
MgmTest Posted March 11, 2014 Author Share Posted March 11, 2014 (edited) 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 March 11, 2014 by MgmTest Link to comment Share on other sites More sharing options...
Yzöwl Posted March 11, 2014 Share Posted March 11, 2014 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: 1or the full version:Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full Value: Install, Type: REG_DWORD, Data: 1Regardless 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 directoryFrom: "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! Link to comment Share on other sites More sharing options...
DosProbie Posted March 12, 2014 Share Posted March 12, 2014 (edited) The OP is working both sides of the fence, posted the same over at MDL yesterday with a working solution by ricktendo64..DP http://forums.mydigitallife.info/threads/53055-not-install-net?p=885450#post885450 Edited March 12, 2014 by DosProbie Link to comment Share on other sites More sharing options...
Yzöwl Posted March 12, 2014 Share Posted March 12, 2014 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. Link to comment Share on other sites More sharing options...
MgmTest Posted March 15, 2014 Author Share Posted March 15, 2014 (edited) 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: 1or the full version:Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full Value: Install, Type: REG_DWORD, Data: 1Regardless 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 directoryFrom: "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 March 15, 2014 by MgmTest Link to comment Share on other sites More sharing options...
bphlpt Posted March 15, 2014 Share Posted March 15, 2014 @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 Link to comment Share on other sites More sharing options...
Yzöwl Posted March 15, 2014 Share Posted March 15, 2014 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! Link to comment Share on other sites More sharing options...
MgmTest Posted March 15, 2014 Author Share Posted March 15, 2014 (edited) Remove x86_64SET "S=\Microsoft .NET Framework 4.0\Setup.exe" Edited March 15, 2014 by MgmTest Link to comment Share on other sites More sharing options...
bphlpt Posted March 15, 2014 Share Posted March 15, 2014 (edited) 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 March 15, 2014 by bphlpt Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now