Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force a process to be started by another process

Tags:

c#

winforms

I have an AutoUpdater application that launches another application. Is there anyway to force that second application to ONLY run if it was started by the AutoUpdater?

The problem is, some end-users will create a shortcut to the main app file on their desktop. This becomes a problem because it's supposed to check for updates to the app before it launches, and they don't receive our updates.

One thought I had was to create an IPC channel via WCF and issue a very simple command from the AutoUpdater to the other application. If the other app doesn't receive that command within 2 or 3 seconds it would close itself.

This seems like more code/overhead than what should be needed though. Is there an easier way?

Thanks!

like image 557
Adam Plocher Avatar asked Feb 17 '23 12:02

Adam Plocher


1 Answers

Windows forms applications also have a main method, which can take parameters. You could read some parameter, and if it doesn't conform to your rules, you can either keep the form from opening (therefore the user wouldn't see a thing), or you can chastise the user, I mean, give a message that they shouldn't open your app that way. I think this is simpler than using WCF.

like image 59
Geeky Guy Avatar answered Mar 03 '23 04:03

Geeky Guy