Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can i disable the .exe file i have made after certain days like 30 days.
It's not about running trial on pc for 30days but simply disable exe after 30days of build
Posted

You can run a background thread to compare current date with the build date after every 12/24 hours interval.
 
Share this answer
 
Comments
Hetal Jariwala 18-Feb-13 4:41am    
but it's gng to run on diffrent pcs
Hetal Jariwala 18-Feb-13 4:41am    
and diffrent clients will access them on diffrent tym
Rumnha 18-Feb-13 4:45am    
You have one .exe per pc running on different pcs. And .exe has the code to compare dates. Why do you think this will not work?
H.Brydon 18-Feb-13 15:27pm    
Creating a background thread for this isn't a great way to do it. Simply add a small API that you check every now and then whenever you do something 'important' that compares the current date with build date. This API could be probably 10 lines of code. You don't need a separate thread for that.
Rumnha 18-Feb-13 21:57pm    
Thanks Brydon for looking into this and I would like to learn from you why it isn't a great way to have background thread which check build date after a configurable interval.
using below method and validate to server also
How to make trail of Software using c#[^]
 
Share this answer
 
if you think internet connection is available where your .exe is going to be run.
then you can make a web request "http://www.timeapi.org/utc/now.json" it will return you current date and time. then you can compare this date with your build date and disable your .exe.
the advantage of this is
1 : it will insure that your .exe file will not work after 30 days. even user has refreshed windows cause it is PC independent.
2 : the above solution fails if user change the date time or set to early days just exception
cause your current date time is the local date time of the PC
how to make a web request in c# ?

C#
var http = (HttpWebRequest)WebRequest.Create("http://www.timeapi.org/utc/now.json");
var response = http.GetResponse();

var stream = response.GetResponseStream();
var sr = new StreamReader(stream);
var jsonCurrentDate= sr.ReadToEnd();
//jsonCurrentDate fetch date and time from this.
// and code accordingly
 
Share this answer
 
Comments
Hetal Jariwala 27-Feb-13 0:11am    
but internet connection may or may not be available and if it's not available then also .exe should run
Sm.Abdullah 27-Feb-13 0:37am    
simple .. if connection not available after checking internet connection then depend on user Local time.logic remain the same... once you find your application time expired then set a bool expired. next check that bool first then local time.

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