0

I am working on project in Visual Studio 2017 Community - Windows Form Application - which is supposed to open and manage files from archive, change specific strings from files and some other stuff.

Now, I've managed to do that but now my only question is how to make an .exe program that will run before vb application and check if specific (4.5.2) .Net Framework version is installed and then run the vb application, since .Net Framework is required for running vb application.

And if specific (4.5.2) .Net Framework version is not installed, ask the user if they want to download/install it.

I want it to be all in one file.

Is it possible? and how?

David
  • 2,298
  • 6
  • 22
  • 56
Icet1
  • 1
  • 5
  • Yes, but ClickOnce requires other files in same folder to run (not just 1 .exe file), and i want one file application, why cant it be all packed together in one .exe? – Icet1 Apr 25 '17 at 11:37
  • [It already works that way](http://stackoverflow.com/a/10033128/17034). Don't help. – Hans Passant Apr 25 '17 at 13:03
  • @HansPassant so system itself does that check and prompt you for install by default? – Icet1 Apr 25 '17 at 13:05
  • http://stackoverflow.com/questions/38656770/how-to-publish-deploy-visual-studio-project-as-an-installer/38657333#38657333 This will help you get started creating a exe installer, if you computer doesn't have the required framework, the installer will prompt you to install it, and 9 times out of 10, it will install the missing components for you – user1234433222 Apr 25 '17 at 13:12
  • when i try to install what is required i get this error, i already have Visual Studio: https://s24.postimg.org/wj5tgd21x/image.jpg – Icet1 Apr 25 '17 at 13:37

2 Answers2

0

You could check the registry path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP there you have listed, which .NET Versions are installed.

Con: Your program needs admin rights to check the registry.

Here a link to the MSN page to determine the installed .NET Framework

Edit:

You could use a batch file to check if the .NET node exists. If the node exists, you can use a .NET program to check the installed versions and if the required version is installed.

For your example would this look like:

reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP"

if %ERRORLEVEL% EQU 0 (
    <YourProgramName>
) else (
    <Some output, which informs the user, that .NET is required>
)
Nik Bo
  • 1,410
  • 2
  • 17
  • 29
  • Yes but i cant check registry path/information from vb application if .Net framework is not already installed, i want to check if it is installed before running actual vb application, so i need some program that will pack vb app, check if .Net is installed, and then if it is installed: extract vb app from resource to local drive and run it, else prompt usert for installing .Net framework – Icet1 Apr 25 '17 at 12:16
  • what program language should i use for that? – Icet1 Apr 25 '17 at 12:22
  • @Icet1 You could use a batch file. Please check my edits. – Nik Bo Apr 25 '17 at 12:42
  • is this correct: reg query "HKLM\Software\Microsoft\NET Framework Setup\NDP" if errorlevel 0 ( ECHO Net is installed ) else ( ECHO Net is required ) ------------------------------- Because this is what i get: https://s14.postimg.org/vhohjnp3l/image.jpg – Icet1 Apr 25 '17 at 12:57
  • @Icet1 Corrected the batch command. Please use `if %ERRORLEVEL% EQU 0 (` – Nik Bo Apr 25 '17 at 13:27
  • its working correctly now, but how could i achieve this from within .exe application that is not dependable on .Net, so that that application could do that check and if .Net is installed, run vb application – Icet1 Apr 25 '17 at 13:35
  • @Icet1 I don't know if you find any language, which don't require any installed packages like a runtime or something else. The only way I know would be with a batch file. Maybe someone else knows a language which would support this. – Nik Bo Apr 25 '17 at 13:42
  • Okay, thank you for your time and help, i really appreciate it, i will wait a little bit more to see if someone has better idea – Icet1 Apr 25 '17 at 13:47
  • @Icet1 You are welcome. Would be interesting if there is a way. – Nik Bo Apr 25 '17 at 14:26
  • Yeah, but i dont think anyone is going to give me solution for this, some professional maybe, but i doubt it – Icet1 Apr 25 '17 at 15:07
0

when publishing your project include Net framework it automatically ask to replace if an older version is installed this way is easier I think

D_Element
  • 21
  • 7