Execute an script/application after installing (using VS Setup Project) - visual-studio

I need to execute a Console Application script after installing my application. Depending on the Windows version, it adds some data to the Registry.
How can I do this using a Visual Studio Setup Project?
Note:
I'm saying after because I read in How to execute custom action before installing files when using VS's Setup Project? that it isn't possible to do it before, but it doesn't really matter in my case.

Simply add the custom action under Install node. I don't really understand what you mean by "console application script", but if you mean a BAT file you can write a custom EXE which launches it through ShellExecute.
If you are using a DLL, make sure that "InstallerClass" custom action property is set correctly:
False for Win32 DLLs
True for .NET Installer Class actions

Related

Unique .exe file in visual Studio, C# desktop application

I have C# desktop application created in Visual Studio.
I need to have one executable file, which I can run anywhere. Without compiler or need of having folders of libraries. The .exe file I have in project folder doesn't work alone.
Thanks
Create installable file using any third party software i.e Advance Installer to send your project anywhere.
If it's a .NET application executable then YES you can send it anywhere and run it anywhere having just one file; provided the fact that wherever or whichever machine you are trying to run it; have .NET Framework installed.
Else, you should create a self extracting installer which will not only include the executable but also will have the framework executable. That way wherever you run the installer will first install the framework and then you can run your exe without any trouble.

Register type library during installation

I have added an automation interface to an application I wrote. The type library is stored as a resource in the application, and on startup, the application calls RegisterTypeLib to register the type library automatically.
I just discovered that this call to RegisterTypeLib only works during development, where the application is launched from Visual Studio, because Visual Studio is running as administrator, and the application inherits this. When running the debug build from the command line, or when running the application as installed by the installer, the application is not running as administrator, and the call to RegisterTypeLib fails.
So I suppose I should register the type library during installation (which would also have the nice side effect of making the automation interface available without having to run the application first). The installer is a Windows Installer project in Visual Studio.
Is it possible to do achieve the effect of RegisterTypeLib during installation (and if yes, how)? When the installer solution is open, Visual Studio shows an editor called "Registry" wher one can add keys to the registry, but there's no way I can add each key separately - I need to somehow add the entire type library with a single call, like RegisterTypeLib does.
EDIT: After manuell's hint and some research of my own, the question boils down to this:
I need to call MyApp /RegServer from the installer (which will also create other required registry keys that aren't created by RegisterTypeLib); how exactly does one do this? I added an "Install" custom action in the Visual Studio installer solution, but haven't yet found out how to trigger it.
The usal way is to let the installer launch the application with the command line arguments /regserver or /unregserver. If you use a Framework (MFC/ATL), the handling of all the registration (unregistration) steps are done automatically.
If you want to do all by your self, check the arguments to "main", and call RegisterTypeLib. The Windows installer should launch your EXE with /regserver, if it knows that's a com server.

InstallShield 2012 Spring Express: How Can I Run Custom Action As Administrator On Uninstall?

I'm using InstallShield 2012 Spring Express. I finally figured out that, during the installation for my app, I could run a custom action with an elevated process EXE (application manifest set to "requireAdministrator") if I set its "In-Script Execution" property to "Deferred Execution In System Context."
That's nice.
But now I must be able to do exactly the same thing during the uninstall. So far, even on the paid version of InstallShield 2012 Spring Express, I can't get it to work.
First of all, for the "Custom Actions During Uninstallation" section, there are only two entries, "Before System Changes" and "After System Changes."
I didn't try adding my custom action to "After System Changes," because the EXE that I need to run is part of my package (and thus would have been removed by then.) And so I added it to "Before System Changes." Now for some reason, when I add it to "Before System Changes," there is no "In-Script Execution" option. And because I don't have this option, when my uninstall attempts to run the elevated process EXE, it fails with an error 1721...which is exactly the same error I used to get during the installation, until I changed the "In-Script Execution" option to "Deferred Execution In System Context."
So, how can I get my elevated process EXE to run correctly during the uninstall? Is InstallShield incapable of properly handling this?
Thanks,
JP
You can author a merge module using Windows Installer XML to correctly schedule and sequence your custom action. InstallShield express can then consume that module. See:
Augmenting InstallShield using Windows Installer XML - Certificates
If you aren't comfortable mixing tools ( this is just like writing a DLL in VB.NET and referencing it in an EXE written in C#) then you'd have to upgrade to InstallShield Professional.

Run a condition check after user selects installation folder

I have created a winforms app and a setup and deployment project for that app (VS 2010).
All I need is this:
When a user runs the msi, right after he selects the installation folder I want to check if the main executable of the application already exists in that folder. In that case I want to break the installation and prompt the user to either uninstall the existing application or choose a different folder.
I would like, if possible, to not use any custom installer action. At first, a launch condition (with a file search) seemed to be the right way, but it seems launch conditions (since they are 'launch') run at the beginning of the msi execution and not after folder picking.
Visual Studio Setup and Deployment Projects don't support this type of authoring. It's one of the many reasons that Microsoft removed that project type from Visual Studio 2012.
The only way to do it using this tool would be to build an MSI and then use ORCA to create a transform authoring the validation custom action and scheduling it into the UI as a gating control event. You could then write a postbuild script to apply the transform to the MSI every time it gets built.
Very advanced stuff and frankly not worth the effort. It would be far more beneficial to switch to a tool that supports doing this such as Windows Installer XML (FOSS) or InstallShield 2012 Professional. ($$)

Creating a standalone .exe for a windows application in visual studio 2008?

I have created a windows based application in C# using visual studio 2008 which basically scans for the registry and then fixes the resulting errors. Now using the msi installer i have made a setup and it works fine. However i have met with a new requirement.
Usually after providing the setup to the user/client has to install the setup and when installed, in the installed folder there are lots of .dlls that i had used to create the project. But my requirememt is to create a single standalone .exe using which i wouldnt have to provide my users with the setup file. All i need to do is that using this single .exe file my whole project should execute and perform the same process of scanning and fixing the registry.
I also tried "ClickOnce Deployment in .NET Framework 2.0" and got the error "ClickOnce does not support the request execution level 'requireAdministrator'". and also have gone through the link
"ClickOnce does not support the request execution level 'requireAdministrator.'"
But still i feel that i would be comfortable if i can get a single standalone exe which can execute my windows forms application.
Is there any way to do it?
Any hint with this thing will be really helpful to me.
Thanks in advance
~Viknesh

Resources