Click here to Skip to main content
15,035,723 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a text file, key.txt downloaded with an MSI Installer. Is it possible to configure this installer to read and copy this text file, 'key.txt' to target path during setup/installation ?

Scenario described below:

I) User visits my website, say, abc.com and goes to the download page. He clicks download, so following 2 files get downloaded to his machine at desired location, say:

E:\Downloads\SetUp.MSI
E:\Downloads\Key.txt

II) When he clicks on SetUp.MSI, installation begins. My question, is there a way to read this text file, 'Key.txt' during Setup ? This file should be then copied to target path of exe installation.

I am using VS 2019 DotNet Installer project . Please suggest correct approach.

What I have tried:

I tried doing this using PostBuildEvent of above installer, but this event is not firing during installation.
Posted
Updated 18-Jun-21 6:16am

1 solution

Typically, you would not do this. Besides, what's to stop someone from just copying the key file and giving it to their friends? NOTHING!

Your site could build the .MSI "on the fly", inserting the key.txt into the File table, making sure there's a component for it, then sending just the .MSI file in the download.

Still, putting the key file in the same folder as your .EXE in the Program Files folder DOES NOT SECURE YOUR APPLICATION. Again, there is nothing stopping the user from copying the file and giving it to their friends.

Your "key file" is not secure at all, and is, frankly, useless.
   
Comments
Member 15244870 18-Jun-21 12:38pm
   
The key file will be generated by End users when they click download. We want to automate the process of copying key file . Presently users have to manually copy this data to target location.
If you can suggest something, now.
Dave Kreskowiak 18-Jun-21 12:46pm
   
No, it's not generated by the user. All the user is doing is clicking a button. The key generation is still done by your site code.

And I already told you how it's typically done.
Member 15244870 20-Jun-21 9:49am
   
I checked with client. Their website code generates Key during SignUp of a customer and stores this info in their Database. The problem statement is this-: When customer runs the downloaded app, they should know who is that customer? They will match this key downloaded with app's Installer in their DB and exe being used by customer. So, if this key could be copied to a target location at customer's machine during installation, this issue would be solved
Dave Kreskowiak 20-Jun-21 10:02am
   
OK, this still doesn't make any sense.

To get the path to the customers own key file, you'll have to create a dialog in the .MSI where the user can browse for the file. That dialog is going to have to set a property to hold the path returned.

Insert that dialog into the interview chain during the install.

You'll also have to create a custom action that takes the path in the property set by the dialog and copy the key file to the INSTALLDIR.

When the app is uninstalled, the key file is going to remain and the app folders will also remain, so you'll have to create another custom action that runs only during uninstall to force delete the entire folder chain.
Member 15244870 20-Jun-21 10:55am
   
Thanks, for prompt replies.
Is this possible with Windows service installer? I am using VS 2019.
Dave Kreskowiak 20-Jun-21 11:11am
   
No, you'll have to build your own MSI installer.
Member 15244870 20-Jun-21 11:22am
   
My question was - Is it possible to have such customization in MSI installer for Windows service type project? My app will be of type Windows SERVICE type in C# VS 2019, I shall then build an installer for it to be downloaded by customer as described above. So, can this setup project for Windows service installer in VS 2019 have custom actions etc ?
Dave Kreskowiak 20-Jun-21 11:23am
   
If you're talking about an .MSI installer, then yes, it's possible to do.

If you're talking about the Service Installer project in Visual Studio, no, it's not possible to do.
Member 15244870 21-Jun-21 6:06am
   
Ok, so custom actions are not possible in VS 2019 Windows Service installer ? But in this article , they say it is possible.
https://www.codeproject.com/Articles/26091/Install-Windows-Service-using-Custom-Actions.
Just cross checking with you as this article is for an old version of Dotnet
Dave Kreskowiak 21-Jun-21 10:42am
   
Yeah, in that article, do you see any way at all of prompting the user with a dialog to get a filename?
Member 15244870 23-Jun-21 7:24am
   
Thanks Dave. Could you point any tutorial for creating custom dialog in MSI in VS 2019 ?
Dave Kreskowiak 23-Jun-21 10:06am
   
VS doesn't create .MSI's. You have to use a third party tool to do it, like InstallShield, InnoSetup, Wix, or whatever your preferred tool is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900