Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: evaluation period expire script
I've never placed an expire in my programs, but in hindsight, in some cases I wish I had. In any event, please find attached an "expire" routine that tries to:
;EXPIRE.WBT ; ******************************************************************************************** ; * Expire header for WBT scripts * ; * * ; * Based on the old "Smoke and Mirrors" philosophy. If you drop an entry in the registry * ; * and an *.ini file in the Windows directory, anyone can bypass them. If you drop another * ; * "verification" file in an unknown location, hopefully they'll be looking to the prior * ; * two locations for their solution. Therefore "File2" below should be named something * ; * cryptic that wouldn't look out of place in the system directory. i.e. "instypname.ini" * ; * * ; * This script also tries to combat the practice of individuals to try and bypass the * ; * timeout period by changing their system clock BACK to a time period when the program * ; * was valid or "authorized". * ; * * ; * To make this harder to bypass, use the Char2Num and Num2Char encryption method to * ; * hide the dates within the .ini and registry entries. * ; * * ; * http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Password * ; * ~Tips+Hide~a~Password~-~Simple~Encryption.txt * ; * * ; * It makes the script much bulkier but it works! * ; * jmburton * ; ******************************************************************************************** WinDir = DirWindows(0) WinSys = DirWindows(1) File1 = "%WinDir%111FileName.ini" ; The file used to verify the registry date File2 = "%WinSys%111InstDate.ini" ; The file used to verify the install date ExpireDays = "30" ; Days you want program to run ExpireUses = "300" ; Times program can be used (could be a few thousand) Today=TimeYmdHms ( ) Y = ItemExtract (1,Today,":") M = ItemExtract (2,Today,":") D = ItemExtract (3,Today,":") Date = "%Y%%M%%D%" ; My preferred boiled down date format If FileExist (File2) == @TRUE Then OrigDate = IniReadPvt("Main", "Install", "", File2) ; Has this ever been installed? If FileExist (File2) == @TRUE Then LastDate = IniReadPvt("Main", "Today", "", File2) ; Last date opened... LOL If FileExist (File2) == @TRUE Then GoSub TestInstall reg=RegExistValue(@REGMACHINE, "Software\test\Settings[InstDate]") If reg == 0 Then GoSub first GoSub During Display(7,"Program Stats","Days Used = %Expire%%@CRLF%%@CRLF%Times Used = %Uses%") GoSub StartProggy Exit :first ; First time installation key=RegCreateKey(@REGMACHINE, "Software\test\Settings\") ; Add the install date to the registry RegSetValue(key, "[InstDate]", Date) RegCloseKey(key) IniWritePvt("Main", "Install", Today, File1) ; Create and add the install date to File1 IniWritePvt("Main", "Uses", "0", File1) ; Create and add the number of uses to File1 IniWritePvt("Main", "Install", Date, File2) ; Create and add the install date to File2 IniWritePvt("Main", "Today", Date, File2) ; Create and add today's date to File2 Return :During If FileExist (File1) == @FALSE Then Message ("ERROR", "Date Mismatch! Program exiting...") ; Let's see if they disturbed our files If FileExist (File1) == @FALSE Then Exit If FileExist (File2) == @FALSE Then Message ("ERROR", "Date Mismatch! Program exiting...") If FileExist (File2) == @FALSE Then Exit value=RegQueryValue(@REGMACHINE, "Software\test\Settings\[InstDate]") value2 = IniReadPvt ("Main", "Install", "", File2) If value2 != value Then Message ("ERROR!", "Date Mismatch! Program Exiting...") ; Let's see if they tried to change any dates If value2 != value Then Exit ; Notice we've used File2, not File1 IniWritePvt ("Main", "Today", Date, File2) ; If they made it this far, let's update today's date. ; So far they're within their authorized period. We'll use this later Uses = IniReadPvt ("Main", "Uses", "", File1) Uses = Uses + 1 IniWritePvt ("Main", "Uses", Uses, File1) ; Let's update the number of uses they've had Expire = Date - value ; Have they used it more than the number of days or times allowed? If Expire > ExpireDays Then Message("Expired","Sorry! This Program Has Expired....%@CRLF%Please contact YOUR INFO for a program update!") If Expire > ExpireDays Then Exit If Uses > ExpireUses Then Message("Expired","Sorry! This Program Has Expired....%@CRLF%Please contact YOUR INFO for a program update!") If Uses > ExpireUses Then Exit Return :TestInstall ; Let's see if it's ever been installed or if they've changed their system date. If RegExistValue(@REGMACHINE, "Software\test\Settings[InstDate]") == @TRUE Then RegInst = RegQueryValue(@REGMACHINE, "Software\test\Settings\[InstDate]") If RegExistValue(@REGMACHINE, "Software\test\Settings[InstDate]") == @FALSE Then Message("ERROR!","Unrecoverable REGISTRY ERROR! Program Exiting!") If RegExistValue(@REGMACHINE, "Software\test\Settings[InstDate]") == @FALSE Then Exit If OrigDate != RegInst Then Message ("ERROR", "Install Date Error. Program exiting...") If OrigDate != RegInst Then Exit If Date < LastDate Then Message ("ERROR", "System Date Changed. Program exiting...") If Date < LastDate Then Exit Return :StartProggy Message ("HOORAY!", "All Tests Passed... Let's run the program!")
Article ID: W16202
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38