V
V
Vitaly Chura2018-07-11 16:24:13
C++ / C#
Vitaly Chura, 2018-07-11 16:24:13

How to implement automatic launch of the application?

Good afternoon. Tell a newbie in programming if this can be done.
There is a Win32 application that must be constantly running for users.
Those. when you start Windows, it should be automatically launched, after closing / crashing it should automatically restart.
Google says this is implemented using a windows service. But the problem is that I first need to specify the directory from which to run this program (for different users it can be installed in different places), and then monitor the process and restart the program.
I thought of making WinForms, in which one could specify the path to the program, as well as manage the service. But I did not find whether it is possible to call the service and pass a parameter to it.
Can you tell me how to implement this functionality?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Griboks, 2018-07-11
@Griboks

The easiest way is to drop the program into the startup folder.

A
Alexander, 2018-07-11
@alexr64

But the problem is that I first need to specify the directory from which to run this program (it can be installed in different places for different users)

This is an installer issue.
sc /?
netstart /?
net stop /?

S
Satangelus, 2018-07-12
@Satangelus

In theory, you need to register your program in the autorun registry branch.

In the Windows 7 registry, startup is represented in several branches: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] - programs that run at logon. Programs that run in this section run for all users on the system

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question