I want to call an installer class on a button click in C#. Is it possible? - class

How can I call an installer class on a button click event which read from the registry and also write a value in the registry in C#?

This cannot be done with a single custom action. You should have 2 separate custom actions:
one which is executed on button click and reads information from registry
another one which writes information in registry during install
The second action needs Administrator privileges and should run as deferred with no impersonation in InstallExecuteSequence.
Assuming you want to set installer properties based on what is read from registry, using an Installer Class is not really an option. I recommend using a DLL custom action which gets a handle to the installer session. You can find a tutorial here:
http://www.codeproject.com/KB/install/msicustomaction.aspx

Related

Create different MSIX installers using a flag parameter on a .NET MAUI app

I want to automatically create different MSIX packages/installers for the same MAUI app, so that each one runs a specific code snippet according to a flag parameter.
The user does not have to interact with the app. An installer per flag value has to be created, an once the app is installed and the user double clicks the app icon, the specific piece of code has to be run.
So far, I've tried without success the following approach, trying to create a script that passes the possible values of the flag as installation parameters using the app installer and a protocol, and then trying to publish the different packages in a local path.
I would like to know whether that's feasible or there may be any other approach to get it done.
You can check this comment about .NET MAUI Windows target publishing/archiving.
In the article, the right way to set the MSIX is that you had to create a self-signed certificate and then You could add a couple of extra parameters to also add the sign the MSIX and then trust that cert manually.

Can I change node proeprty value in a AEM custom worklfow process?

I have created a new workflow for activate later. It includes a custom workflow process step written by me. The custom step changes some properties of the payload step and then Activate Page process is called to activate the page. The changed properties are reflected in the author instance but not on the publish instance. Just wanted to confirm if this is possible or the workflow creates a copy of the node and then executes on it (like passing a parameter to a function)?
Thanks in advance :D
It should work fine, however you have to commit changes using resourceResolver.commit()

setting options while installing or after installing App

I want to set the language for one time once the user downloaded the app and started using it, for only first time. but not all the time he use the app. How can i do that?
like how we get select language options , while installing Microsoft products, etc
is this possible ?
you can control that when you application apears. Did you know about property lists?
You could use it. Or maybe you can create a file with Core data with name Configs. You need to check if field is blank and case yes, open a viewControllerChangeLanguange.After select save the data and start your application. Remember, everytime you start you will check your file. Case exists, set current language.Case not, invoke an interface to user select a language. All the controller could be made by just a file config.

Windows XP control panel - providing a value for the "comments" field

Where does the Windows XP control panel get the value for the "Comments" field from? I'm writing an EXE control panel application, and it doesn't appear from the documentation that you can provide a value for that field.
Registering an Executable File (exe) as a Control Panel Applet on Windows Vista using Windows Installer XML (WIX) at Link
[previous answer]
See the Executable Control Panel Item Registration of Registering Control Panel Items at http://msdn.microsoft.com/en-us/library/cc144195(VS.85).aspx
Specifically, you want InfoTip, which is the comments.
Registering Control Panel Items
Control Panel items must be registered
in order to appear in the Control
Panel window. If the Control Panel
item is implemented as part of a .exe
file then it is registered as a
command object. Registration differs
if the item is implemented as a .dll
file that exports the CPlApplet
function.
Using CPLApplet:
When Control Panel loads a .dll (or
.cpl) file, it calls the CPlApplet
function to get information such as
the number of Control Panel items the
file hosts, as well as information
about each item.
When Windows first loads the Control
Panel item, it retrieves the address
of the CPlApplet function and
subsequently uses that address to call
the function and pass it messages. It
might send the following messages.
You need to handle CPL_INQUIRE Message and fill the CPLINFO Structure.
typedef struct tagCPLINFO {
int idIcon;
int idName;
int idInfo;
LONG_PTR lpData;
} CPLINFO;
idInfo is the resource identifier of the string containing the description. You cannot simply set this thing by filling in some registry key.
Edit: Ok, my bad, this is an old solution.
This string is retrieved from the HKCR\CLSID{guid}\InfoTip registry value. How to whack the registry into shape is explained very well in this MSDN Library article, not much I can add to that.

How to run my program on before logout on windows XP?

I am looking for an inverse version of "RunOnceEx".
RunOnceEx does run some program, before the user's shell(desktop&taskbar) start. The login progress will not continue before the runonceex complete.
I want to do exact the same but on user logout.
When she/he logout, all running program shutdown, leaving shell(desktop&taskbar), then ""I wish my program will be execute this moment"", finally logout.
I think it is possible because the "mobsync.exe" is doing that. But I cannot find where and how to do it.
Warning, as said here, gpedit.msc will allow you to configure a logoff script for all users.
If you need that script only for one user, you need to declare it directly in the registry, both in HKCU and HKLM.
To run this only for the current user, you can use WMI to get an information when a shutdown/logout occurs.
Either you write a small C# (or any other language that can use WMI) application or vbs script to listen on the Win32_ComputerShutdownEvent WMI event.
An example C# app can be found here in this question: Get Log off event from system
found in the first result on google for me
To execute a program you can create a script to run it and use group policy to enforce it.
In Group Policy Editor navigate to User Configuration-->Windows Settings-->Scripts (Logon/Logoff)
more information here
If you want a running program to execute code on logoff, then you should hook the WM_QUERYENDSESSION message and look for an lParam value of ENDSESSION_LOGOFF (0x80000000).
It's important to test for this lParam value because the other ones indicate a "forced close" - i.e. your process may be killed before your code is even allowed to run. In fact, most shutdown/session-end messages are only intended to give you an opportunity to run last-minute cleanup code and aren't that safe to respond to with long-running actions; but this particular combination should be OK.
Note: I've never tried to actually run a separate process in response to the WM_QUERYENDSESSION message. It's possible that the window manager will disallow this, like it does during shutdown. Try it and see, I guess.
If you're in a .NET environment (you didn't specify), a quicker way is to add an event handler to the Microsoft.Win32.SystemEvents.SessionEnding event.
What you need is an implementation of GINA. You can run your custom commands in WlxIsLogoffOk function, which gets called when the user initiates a logoff
Once you create the proper GINA dll you can register it here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\#GinaDLL
Here is an implementation which may fit your needs (it provides a Logoff registry key where you could specify your command):
http://wwwthep.physik.uni-mainz.de/~frink/newgina_pre09/readme.html
As VonC and TFD already mentioned, the Group Policy Editor is just another way to manipulate the registry.
Just make with gpedit the changes (in Userconfig - Windows Settings - Scripts) you like and afterwards take a look in the registry at [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts]
to find out how you can do that directly.
Also on my PC (hanging in a domain) is a hidden folder C:\WINDOWS\System32\GroupPolicy with subfolders for user and machine. Both having additional subfolders called Shutdown and Startup. Maybe you can also use these ones.
If you need something simple and working for a single (or any) user you can make a simple application in C++ or C# for example.
The simplest is having a C# in tray (by simply adding the tray component to the form) and register and event handler for the FormClosing event. It'd look like this:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason != CloseReason.UserClosing)
{
// It's not the user closing the application,
// Let's do whatever you want here, for example starting a process
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";
notePad.Start();
}
}
So your application will be started with Windows or with the user. It'll wait (using a little bit of memory) and will do something when the system shuts down, or the user log off, etc (by checking "CloseReason" above).