-
April 21st, 2011, 01:56 AM
#1
[RESOLVED] Disallowing user to run application
Like many program's updater I'm trying to make my own updater which will not allow users to run it by double click.
It can only be started from my main application by ShellExecute.
What should be the ideal approach for this ?
◄◄ hypheni ►►
-
April 21st, 2011, 04:34 AM
#2
Re: Disallowing user to run application
Why on earth do you want people not to run a program??
Anyways, perhaps the updates that are running may not be launched by an exe, ever thought of that?
-
April 21st, 2011, 04:45 AM
#3
Re: Disallowing user to run application
Originally Posted by HanneSThEGreaT
Why on earth do you want people not to run a program??
Anyways, perhaps the updates that are running may not be launched by an exe, ever thought of that?
Because I don't wanna run the updater from user end at least on the Earth.. :P
The updater will launch from my main application and kill application if it needs to be updated.
◄◄ hypheni ►►
-
April 21st, 2011, 05:04 AM
#4
Re: Disallowing user to run application
Originally Posted by hypheni
Like many program's updater I'm trying to make my own updater which will not allow users to run it by double click.
It can only be started from my main application by ShellExecute.
What should be the ideal approach for this ?
One thing you can do is add the updater.exe file to your main application resource as a bin resource when you will want to use it simply extract it to disc as exe, and launch it.
When it launched it will close your main application and will do whatever it takes for the update.
But keep in mind that each time you run the main application, make sure you delete the updater.exe so it won’t remain on the disc.
This thread might help. (it deals with bmp file but its the same thing for any type of file)
Cheers
-
April 21st, 2011, 07:24 AM
#5
Re: Disallowing user to run application
Thats not my goal. Binding exe as resource with application - I did a lot earlier. You can find my old posts about this which helped other so this is not the way.
Im talking about the actual procedure which many software's updater uses. For example Garena (a virtual gaming client) updater uses the same mechanism. You cant run the updater by double clicking. It will show you error that "You can't run updater in this way."
◄◄ hypheni ►►
-
April 21st, 2011, 07:32 AM
#6
Re: Disallowing user to run application
Hmmm... Just a quick shot - there may be a far more elegant solution...
Why not simply define an undocumented command line option for the updater and pass that when invoking the updater from your main app? If the option is not present the updater refuses to run.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
-
April 21st, 2011, 07:43 AM
#7
Re: Disallowing user to run application
Yes thats a good idea. I will give a try and post here..
BTW. "hmm" is used in Germany too ?. I thought its only Indian shortcut to say "Yes" online.
◄◄ hypheni ►►
-
April 21st, 2011, 07:53 AM
#8
Re: Disallowing user to run application
Originally Posted by hypheni
Yes thats a good idea. I will give a try and post here..
BTW. "hmm" is used in Germany too ?. I thought its only Indian shortcut to say "Yes" online.
Usually it's used to indicate somebody is thinking.
-
April 21st, 2011, 07:54 AM
#9
Re: Disallowing user to run application
◄◄ hypheni ►►
-
April 21st, 2011, 07:58 AM
#10
Re: Disallowing user to run application
hmm, Sorry, my original post was not very helpful. I understood your question wrong.
-
April 21st, 2011, 04:08 PM
#11
Re: Disallowing user to run application
Another option might be to have your installer check to see if your main app is already running. If not, issue an error, and close.
Viggy
-
April 21st, 2011, 06:19 PM
#12
Re: Disallowing user to run application
Originally Posted by Eri523
Why not simply define an undocumented command line option for the updater and pass that when invoking the updater from your main app? If the option is not present the updater refuses to run.
Another (but similar) idea is to modify the environment variables passed to the child process when using CreateProcess to start your updater, to include a custom variable that your updater checks for.
This is one of the Microsoft-recommended ways to pass information from a parent process to a child process.
For an example, see "Changing Environment Variables" at http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx . Look at Example 2, which sends the child process an environment variable named "MyVariable".
Mike
-
April 22nd, 2011, 09:16 AM
#13
Re: Disallowing user to run application
It can only be started from my main application by ShellExecute.
So it would be logical to check in updater on its start what process ran it (by parent process id). And quit if it was not your main app. This is going to prevent from env variable frauds.
Best regards,
Igor
-
April 22nd, 2011, 11:08 AM
#14
Re: Disallowing user to run application
Nice idea Igor. But checking command line argument is much easier way. But of-course your procedure is more robust.
Anyways I stick to command line argument checking. A simple strcmp() can do it.
Last edited by hypheni; April 22nd, 2011 at 11:19 AM.
◄◄ hypheni ►►
-
April 24th, 2011, 11:14 AM
#15
Re: [RESOLVED] Disallowing user to run application
Why not just build your updater code as a DLL instead of an exe? That way, your main app would be able to run the updater but ordinary users wouldn't.
"A problem well stated is a problem half solved.” - Charles F. Kettering
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|