WPF - Installing the certificate automatically for client - c#

We have a program in WPF. In order for clients to run this program, they first need to manually install our certificate on their PCs.
Is there a way to make the program automatically prompt the user to install the certificate or approve installation of certificate ?

http://technet.microsoft.com/en-us/library/cc732061%28v=ws.10%29.aspx
Create a bat file and run this, either as a process inside your main application like a first run sort of deal or have it execute as part of your installer.

Related

WIX Installer do not run C# process properly

We have a big WIX Installer. After the installation, there are around 2800 scripts that should be run to upgrade the database. For that purpose, a special application is created. It just goes to the SQL machine, installs prerequisites like SQL SMO and SQL Sys Clr Types, and executes scripts. This small application is run in custom actions in WIX. Logically, it should be run with elevated privileges. In this custom action, I am using c# Processes to start the app. However, I have tried everything, and the application is still not working properly. It opens the app and app tries to install prerequisites and just exits - nothing is installed. What I have tried:
1. Running process with elevated privileges (process.StartInfo.UseShellExecute = true)
2. Running process with user privileges (standardinput/output with UseShellExecute=false)
3. Running the app with a batch file.
Overall process should be as following:
Installer is run with elevated privileges -> After installation, special application is run to upgrade the database -> the app installs prerequisites -> the app executes scripts.
The interesting part is that application is working properly when I do it manually with cmd. However, when installer's custom action opens cmd.exe (c# Process) and it is still waiting, then manually opening application via cmd is not working. In other words, I have cmd (with elevated rights) opened by installer and another cmd opened by myself manually. Then, manual running the application is not working. As soon as I close the cmd opened by the installer, and run manually the application via cmd that was opened by myself, then again everything is fine, everything is working.
I need a help how can I fix this?
P.S. The installer's prerequisites cannot be extracted and installed separately. We do not have source code of upgrade database application.
After some research, I have found that Windows cannot run two MSI at the same time and therefore, second MSI was silently quitting.

Custom Application updater

I have created a code, which compares XML files on the client side (in PC) with the XML file located on the FTP server; where once it detects that client is running older version of the program, it will download the latest build (so that user has always up to date program).
Here is the trick. Due to the fact, that I am overwriting files at run-time, I had to create an external console application which is being called from the main app if user wants to update. This way, first console application is executed and afterwards main app is closed, so that no files are locked by the system (application's .exe file would otherwise be locked and we could not replace it with the new one).
This process runs perfectly, if it is being installed somewhere else other than under the system folder (by that I mean e.g. C:\Program Files\ drive). If user has decided to install main application there, then suddenly my app crashes as it does not have admin privileges.
I am using Install Shield LE when disbursing this app, and users that are using this program are not administrators (which means that I go to every computer and type admin password when I/users install this program).
Is there a way, how to execute my updated console application with admin rights, or how to define via Install Shield that once this app has been executed, I always want it to be executed as admin?
Hope that my explanation has not been confusing. I am more than happy to share additional details if necessary, as I need to figure out how to solve this thing.
I imagine you don't have an AD configuration as Emmanuel suggest, because in this case you would push the updates without any problems and would not have to design an automatic updater.
I don't know if InstallShield has something like this, but Advanced Installer has the support to install a dedicated updater that runs as a service, thus it has all the permissions required to install an application under Program Files.
Of course this means you need to replace your updater with the one from Advanced Installer and also that the initial installation of the application on the end user machines will still require admin credentials. (future installs can install silently, without the user's intervention)
You'll need to add the following line to your app manifest:
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Documentation on the msdn is here.

How can I add window Service in C#/ install it and Run exe(My Job.exe) through this Window Service?

Actually I want to run exe file(My Job.exe) Through window Service in C# but window service should be started automatically when I start the Computer?
I have already added Window Service (MyService) manually. I have also setup project of My application where I also added this service so that I can also be installed when I install my Application.
I have serviceInstaller1 with property
StartType=Automatic;ServiceName=MyService.
I also have serviceProcessInstaller1 with Property
Account=LocalSystem;
When I run this my Applicationo gets installed but MyService don't get installed and I also not see it in Service of Computer Management.
Could any body please help me I already spend two days on it but not finding proper guidline. thanks in Advance.
How is your application being installed? Did you create an installer (.msi file) for it? It sounds like you're trying to implement your own installer instead of using existing tool to do this.
I recommend Advanced Installer. It is a very powerful installer generator and has all the features you need in the free version, and more importantly, it's very easy to use. This tool lets you create an install wizard with the ability to patch and uninstall your software (including services, registry values, files, etc).
I recently have one project with windows service in VS2010 and .Net 4.5 and user OS will be Windows Server 2008. I was unable to create fully functional installation a long time, and still i dont have, but request are changed so no need for installation file. But i can give you advice "How to do".
If you don't have purchased version of InstallShield you need to find some other program for creating installation file.
For installation you need just to copy you .exe output of service and one batch file witch will have next content:
#ECHO off
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" "%~dp0%<filename>.exe"
pause
and then you need to run with administration rights this batch file.
Both files (.exe and .bat) must be in same folder.
You can delete pause command but then you will not see if registration of service was successfully.
Make sure that you have installed target .NET Framework on PC.
I hope that this will help you.
If you just need to run your exe file(My Job.exe) when the system starts up you could add your exe to the Windows Task Scheduler.
Is there any specific purpose for using a Windows service?
The reason that I am saying this is that you have a wide variety of options to invoke you exe as follows
Schedule based on common recurring events, i.e. When the computer starts or When a user logs on.
Schedule based on the calendar, i.e. Daily, Weekly, Monthly, or One time.
Advanced options like execution based on events, etc.

Install application in window 7 without UAC using C#

When I install my C# app in windows 7, UAC always shows. I'm not logged in as Administrator but I want my application to be installed without the UAC.
Can you give me ways on how to do it?
The UAC prompt shows for any number of reasons, none of which is "the code inside the exe calls function X or tries to write to place Y." These include:
the name contains setup, patch, update etc (eg setup21.exe) and there is no manifest
you embedded a manifest that asks for requireAdministrator. You would have done this on purpose in Visual Studio.
there is an external manifest (for NewApp.exe it would be NewApp.exe.manifest) in the same folder that asks for requireAdministrator. You would have done this on purpose too.
you have right-clicked the exe, and on the Properties Compatibility you have chosen to elevate it, or to run as XPSP2 which for 7 also elevates
someone in your company has applied a Group Policy that this installation app should run elevated (unlikely)
you once ran it, got a dialog from Windows saying "that may not have worked right" and agreed to try again with "recommended settings"
Do any of these seem likely? If so, correct them and see if the UAC prompt goes away.
Single Package Authoring link text
You'll want to use Windows Installer / Windows Installer XML to make this install behave the way you request.
If you want to install an app without UAC then you can only touch folders that the currently logged in user can write to. Google Chrome does this--it installs the entire application to the user's local application data folder.
It's very non-standard and I would argue MS should prohibit running code from this location, but it's a working solution to requiring administrator/UAC access to install applications.
Incidentally, Google Chrome more recently made a traditional installer available so one user can install it to be used by all users on the computer.
If you want your application to be installed without triggering the UAC, install to %APPDATA% (instead of installing to %ProgramFiles%) and write to the HKCU hive only in the registry (i.e. don't try to write to HKLM, HKCR, etc.)

Running an installer or checking to see if a program is installed

I have a program that I want to use as an autorun. I want it to be able to do three things. It needs to check to see if a specific program is installed, if it is not, present the user with the option to install it. Second, if the program is installed, present the user with the option of running it and uninstalling it, third, present the user the option to view a readme.
How can I get a program to check and see if another program is already installed?
How can I launch an installer/uninstaller from another program?
Thanks.
P.S. I can modify the installer.
Assuming its your program and you're building the install, I'd just have your installer write to a registry key and then check that key in your autorun program.
To launch the installer from your autorun program just run the setup.exe, or use MSIEXEC for an MSI.
Assuming your installation is Windows Installer based, everything you need is here.

Categories

Resources