Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to call windows services .exe file from wpf application or we should create window service dll to call it from WPF application?

What I have tried:

I have create Windows services .exe file and trying to call service from WPF application 'on button click' like this-

private void Btn_Click(object sender, RoutedEventArgs e)
{
string myOtherEXE = "WindowServcice.exe";
string path = @"C:\WindowService\bin\Debug\WindowService.exe";
Process.Start(path);
}
Posted
Updated 6-Apr-20 23:10pm

You can't start a service from a "regular app" - you have to install the service "properly" using
installutil.exe /i MyService.exe

Then start them with services.msc if you need to - they normally start when Windows boots up.
 
Share this answer
 
If you don't mind digging around in some code, I wrote an article a number of years ago that allows you to install, start, and stop a service from within an application.

This is the article - SQLXAgent - Jobs for SQL Express - Part 1 of 6[^]

On the left side of the page, click "Browse Code". A tree view of files in the project will be displayed.

Look for the "SQLXAgent" folder, and then look for the ServiceStatus.cs file.

You'll have to make changes specific to your app and service, but everything you need is there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900