Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Application
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 17-Feb-13 22:22pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can run a background thread to compare current date with the build date after every 12/24 hours interval.
  Permalink  
Comments
Hetal Jariwala at 18-Feb-13 4:41am
   
but it's gng to run on diffrent pcs
Hetal Jariwala at 18-Feb-13 4:41am
   
and diffrent clients will access them on diffrent tym
Rumnha at 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 at 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 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

using below method and validate to server also
How to make trail of Software using c#[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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# ?
 
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
  Permalink  
Comments
Hetal Jariwala at 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 at 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)

  Print Answers RSS
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 212
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 146
0 Sergey Alexandrovich Kryukov 6,077
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100