Embed custom code in ClickOnce setup.exe?

I know that you can pass parameters through the URL of ClickOnce applications running on the Internet. However, most users download setup.exe and run it from their computer. Is there a way that I can overwrite setup.exe at startup, paste the code (say, the user's email address), and then run the application with knowledge of the code? Suppose we can somehow rewrite setup.exe so that it is legal.

Suppose .NET 3.5.

Refresh . The goal here is to transfer either the email address and / or referrer information to the setup.exe file, so that even when the user starts the installer from another machine and another ip, we can make a referral.

Update 2 Suppose .NET 3.5 SP1 helps? Apparently, you can now pass .application options while offline. Is it possible to embed parameters in the setup.exe file so that it calls .application? Ref = is someone right when running setup.exe?

+6
source share
5 answers

Well, if your goal is to embed the client identifier (email address, code, etc.) in exe, the easiest way I can think with is IPropertyStorage and IPropertySetStorage . If you feel brave, you can call the methods directly on IPropertySetStorage via p / invoke , or you could take the easy route and use the Microsoft-prepared COM shell called dsofile.dll .

Please note that while dsofile is for office documents, it really works with any file - including .exe files - you are just stuck with predefined property names. Why not throw your customer id into something like the .Comments property. Just do it so that you can take it apart again.

Here is an example:

var doc = new OleDocumentPropertiesClass(); doc.Open(pathToFile); doc.SummaryProperties.Comments = " joe@test.com "; doc.Save(); 

Of course, you need to first copy it to a temporary location, and some time after downloading it, you will want to delete it.

You can associate dsofile.dll with your application and register it as a dependency and use it in your installer to read the property back. Or, if you can p / call IPropertyStorage without it, then you will not have a dependency.

Another thing to learn is to use the advanced file properties that Shell32.dll reads. I just couldn't find an easy way to write them easily. If you go this route, share how you wrote the properties in your .exe.

+4
source

See if the InPlaceHostingManager class can help you in this case. This probably will not do what you requested. But it can help ...

Any ClickOnce application based on a .exe file can be silently installed and updated by the user installer. The user installer can embed user experience during installation, including custom dialogs for security and maintenance operations. To perform the installation, the custom installer uses the InPlaceHostingManager class.

Walkthrough: Creating a Custom Installer for a ClickOnce Application

EDIT

I'm not sure that you could achieve what you want, exactly as you described in the question. Check if these threads help.

Access local and remote data in ClickOnce applications

How to include user data files in a ClickOnce deployment?

How to get query string information in ClickOnce online application

+1
source

How can you imagine rewriting setup.exe at boot time? if instead of opening your application with the provided link (URL), users download the file locally directly from a network share, you cannot intercept it.

I would try to play with permissions and ask users to execute it from the link provided to them, but could not directly connect to the shared or web address and download it. Not sure if this is possible.

0
source

You can try to embed this information as a resource in exe. Here is an example of a C ++ exe resource update. http://msdn.microsoft.com/en-us/library/ms648008(v=vs.85).aspx#_win32_Updating_Resources

0
source

You have to combine the Charith and Josh approach - essentially tweak your web server so that you can generate a new tweak based on URL parameters. Use a special installer to read from referral information from the resource for setup.exe. Check this link on how to manage resources for your own application in C # - you need to write to the resource file when creating the setting and read it from your custom installer.

Another way to generate a custom setup would be to create your executable or auxiliary assembly from a command line that embeds the necessary information. Then create the setting from the command line tools (see http://msdn.microsoft.com/en-us/library/xc3tc5xx.aspx ). It looks rather cumbersome and takes a long time to create a custom setting, and not to change the resource of an already built installation.

A completely different approach is to send a unique referral code (registration code) whenever the user downloads the application. In the setup (or application), use a special installer to request a user for this code. If the setting is called via a URL, then the code will be accessible from there, in which case the user installer does not need to request a code. The email that you send when the user downloads the installation should inform the user about the need for a preliminary code in a text file along with the installation file.

0
source

Source: https://habr.com/ru/post/896537/


All Articles