• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
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

bat2exe >>>>> aaa.cmd=run.exe

@ECHO OFFSETLOCALSET "M=Oasdsd.exe"SET "S=Microsoft .NET Framework 4.0\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%" (START "" /WAIT "%_%%S%" /q /norestart && (SET F=Yes))
0

Share this post


Link to post
Share on other sites

Since I do not currently run a Windows OS, my scripts are not tested!

Try this slightly altered version:

@ECHO OFFSETLOCALSET "M=Oasdsd.exe"SET "S=Microsoft .NET Framework 4.0\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 :EOFIF NOT EXIST "%_%%S%" 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:PRESTART "" /WAIT "%_%%S%" /q /norestart && (SET F=Yes)

<EDIT />

If you intend to wrap my script into an executable, I ask that you credit me in the file properties of that executable.

0

Share this post


Link to post
Share on other sites

Well, if I may :unsure:, the FIRST rule of the Batch club is "You do not use bat to exe converters", the SECOND rule being "You DO NOT use batch to exe converters" ;).
Seriously, save the thing with extension .cmd and test it AS IS, then, and only IF it works as "plain" .cmd, you may try to convert it to a .exe, knowing that there are two kinds of batch to executable converters:

  1. the type that is nothing but a SFX (self executing archive) that will expand the batch *somewhere*, typically in %TEMP% folder and run it from this location
  2. the type that is an actual sort of compiler but that with a rate that I would estimate between 70 and 95% :w00t::ph34r: completely FAILS to compile a working program unless it is very - and I mean VERY - basic

For the first you need to make sure that relative paths and similar resolve correctly, for the second kind usually there is nothing that you can do, a given batch either works or it does not.

jaclaz

Edited by jaclaz
0

Share this post


Link to post
Share on other sites

If you leave it in the "aaa.cmd" form, do you get the same error? Any error's thrown should indicate the line number and character position of the error.

Cheers and Regards

0

Share this post


Link to post
Share on other sites

I use Advanced BAT to EXE Converter PRO v2.83 to convert bat to exe, I used it before and I didn't have any problem ,how can it create problem ?and whats that problem?

0

Share this post


Link to post
Share on other sites

If you continue to ignore my posts you will receive no further help and I will ask that you no longer use any of the code I have provided.

0

Share this post


Link to post
Share on other sites

Not Install .Net And Send Error.

1394887538391.png

bat2exe >>>>> aaa.cmd=run.exe

@ECHO OFFSETLOCALSET "M=Oasdsd.exe"SET "S=Microsoft .NET Framework 4.0\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%" (START "" /WAIT "%_%%S%" /q /norestart && (SET F=Yes))
0

Share this post


Link to post
Share on other sites

I've attached the script I posted earlier which you ignored, I have wrapped it as an .exe and have also tested it on a Windows OS with success.

The script will not actually install anything, it will only tell you what it would do if I hadn't prevented it.

<EDIT />

Removed download - no longer required

Edited by Yzöwl
see <EDIT />
0

Share this post


Link to post
Share on other sites

I use Advanced BAT to EXE Converter PRO v2.83 to convert bat to exe, I used it before and I didn't have any problem ,how can it create problem ?and whats that problem?

Seriously, save the thing with extension .cmd and test it AS IS, then, and only IF it works as "plain" .cmd, you may try to convert it to a .exe, knowing that there are two kinds of batch to executable converters:

  • the type that is nothing but a SFX (self executing archive) that will expand the batch *somewhere*, typically in %TEMP% folder and run it from this location
  • the type that is an actual sort of compiler but that with a rate that I would estimate between 70 and 95% :w00t::ph34r: completely FAILS to compile a working program unless it is very - and I mean VERY - basic
For the first you need to make sure that relative paths and similar resolve correctly, for the second kind usually there is nothing that you can do, a given batch either works or it does not.

If you leave it in the "aaa.cmd" form, do you get the same error? Any error's thrown should indicate the line number and character position of the error.

If the code doesn't work in "aaa.cmd" form, then there is probably something wrong with the code. If it doesn't work in "run.exe" form then there is no way to know if there is a problem with the code, the conversion, or the phase of the moon. First things first. Confirm whether the code works in "aaa.cmd" form. DO NOT even try to convert to "run.exe" form until it is working correctly in "aaa.cmd" form. I know you say you do not need things like the check for x86x64, but try Yzöwl's code UNALTERED and let him help you get it working correctly before you start taking things out of it. As long as we are giving you one set of code and you are testing a different set, then there is no way to know where your problems are occurring. But then, if you don't want any help ...

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

Edited by bphlpt
0

Share this post


Link to post
Share on other sites

I've attached the script I posted earlier which you ignored, I have wrapped it as an .exe and have also tested it on a Windows OS with success.

The script will not actually install anything, it will only tell you what it would do if I hadn't prevented

thanks for your code,could you plz edit this code?,I change the .Net Folder witch name with &,and introduce software name of convertor witch convert batch files to exe,

test file but not install & any key exit BatScript.zip

@ECHO OFFSETLOCALSET "M=Oasdsd.exe"SET "S=Microsoft .NET Framework 4.0\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%" (START "" /WAIT "%_%%S%" /q /norestart && (SET F=Yes))
Edited by MgmTest
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.