How to detect a running MSI Installation [duplicate] - c#

This question already has answers here:
How do I test if another installation is already in progress?
(3 answers)
Closed 7 years ago.
I'm looking for a way to detect if a Windows Installer installation is already in progress. What I've found out so far is:
Checking the Registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\InProgress
Using the Windows Installer API function MSIInstallProduct with a dummy file which then would return the specific error code.
Does anybody know a smarter solution?

Same as this:
check for windows installer mutex availability
and this:
http://blogs.msdn.com/b/heaths/archive/2006/01/23/516454.aspx
Question 1:
http://blogs.msdn.com/b/windows_installer_team/archive/2005/11/09/487559.aspx

Related

How to get a WPF app to open another app if it exists [duplicate]

This question already has answers here:
Check if an executable exists in the Windows path
(8 answers)
Closed 3 years ago.
I am working on a WPF app, and I would like to include a button that directs it to another app. I would like it to have the following functionality:
If the app is installed on the user's computer, it opens the app for them.
If the app is not yet installed, it sends them to a link where they can download the app.
I know I will need to use Process.Start to open the app, but I am stuck on how to check if the app exists. If anyone could point me in the right direction it would be appreciated!
Two things you can use:
File.Exists(string) - Checks if the file exists.
try-catch - Simply try to open it, and handle any exceptions.
I would probably opt for the first solution...

How to make an installable .Net console app [duplicate]

This question already has answers here:
C# set environment variable
(2 answers)
Ways to deploying console applications in C#
(5 answers)
Closed 4 years ago.
How can I make my console app installable so that when I open CMD I can run it from anywhere with a keyword. Like when I type in git in cmd for example. Thanks.
For this, you need to set up an environment variable called PATH. In Windows, it is in the registry. But for Mac or Linux you may want to update the .bash_profile file.
You can use the following function
SetEnvironmentVariable(String, String)
Here is the link for the MSDN .net core API
Then again I haven't tried this before. But hope this helps you out.

Check if [path to exe] has running instance? [duplicate]

This question already has answers here:
Check if a specific exe file is running
(8 answers)
Closed 5 years ago.
Is there a way to check (using C#) whether there is an instance of an EXE that is refered to by path running? If so, please provide the method of doing so. Thank you in advance.
Example: Is there a way to find out if "C:\foo\bar.exe" has a running instance, by refering to the EXE as "C:\foo\bar.exe"?
Do you want something like that;
public List<Process> GetProcessesByFileName(string fileName)
{
return Process.GetProcesses().Where(x => x.MainModule.FileName == fileName).ToList();
}

How to make file to be opened by my app? [duplicate]

This question already has answers here:
Where does Windows store its "Open With" settings?
(3 answers)
Closed 9 years ago.
I have a little bit confusing problem. I'm not a beginner but I don't know how to do it..
For example I've written a program like notepad from which you can open files, save and etc. But when I set any custom format like ".blabla" to be opened by my app it is not working, so how can I make it to be opened by my app?
It is in WinForms
You need an entry in the registry for custom file extensions. You can try inserting a key in the registry as follows:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\

C# launch power options [duplicate]

This question already has answers here:
How can run functions of powercfg by C# code?
(3 answers)
Closed 9 years ago.
From my C# program I want to open the power options from the control panel in Windows.
However I can't seem to find out how to do that, I tried making a shortcut and see where it goes but it is referring to the control panel.
Does anyone have an idea how to do that or where the exe is located to launch?
Try the following:
System.Diagnostics.Process.Start("powercfg.cpl");

Categories