Click here to Skip to main content
15,564,017 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 7: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.
 
Share this answer
 
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.

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