I tried to make a func which allows you to activate your script.exe on a PC and nobody could use it on other PCs.
This UDF writes a pseudo unique key to the registry during activation. After activation you put one line of code at top of your script and then it will exit if the keys don't match.
Tell me what you think about it...
#include <String.au3> ; Added the option to specify whether it runs only on this windows, or this harddrive. If _runOnlyOnThis("", "", -1, "test", 1) <> 1 Then Exit (0) ; Put your script code below here MsgBox(64, "Secured Program", "Yeah, the secured main-program started!" & _ @CRLF & @CRLF & "Thanks & and have fun!" & @CRLF & @CRLF & "Mega") ;=============================================================================== ; ; Function Name: _runOnlyOnThis ... ; Description: Activation by parameter sets a unique registry key ; After a successful activation, checks for the regkey ; If correct go on, else Exit(0) ; ; Parameter(s): (Script) First time, the activation key ; (Func) $s_KeyName = RegKeyName ; $s_EncryptPassword = Encryption passphrase ; $i_EncryptLevel = Level (quantity) ; $s_ActivationKey = key which starts the func ; $i_Option (default =1) ; ; _runOnlyOnThis ... $i_Option ; 1 = Windows installtion (Date) ; 2 = HardDrive ; ; Return Value(s): On Success - Returns 1 ; On Failure - Returns -1 RegWrite Problem, ; Returns -2 Not activated, ; Returns -3 Wrong registry key ; Returns -4 Couldn't DriveGetSerial ; ; Note(s): Basically useful to prevent user starting the script on ; non activated PCs ; String.au3 has to be included ; ; Author(s): Thorsten Meger ; ;=============================================================================== Func _runOnlyOnThis($s_KeyName, $s_EncryptPassword, $i_EncryptLevel, $s_ActivationKey, $i_option = 1) If $s_KeyName = "" Then $s_KeyName = "Version" If $s_EncryptPassword = "" Then $s_EncryptPassword = "thisPc" If $i_EncryptLevel = -1 Then $i_EncryptLevel = 2 If $s_ActivationKey = "" Then $s_ActivationKey = "activate" If $i_option <> 1 Or $i_option <> 2 Then $i_option = 1 If $i_option = 1 Then Local $stringToCrypt = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "InstallDate") ElseIf $i_option = 2 Then Local $stringToCrypt = DriveGetSerial(StringLeft(@SystemDir, 3)) If @error = 1 Then Return -4 EndIf Local $crypted = _StringEncrypt(1, $stringToCrypt, $s_EncryptPassword, $i_EncryptLevel) If $cmdLine[0] > 0 And $cmdLine[1] = $s_ActivationKey Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\" & StringLeft(@ScriptName, StringLen(@ScriptName) - 4), $s_KeyName, "REG_SZ", _ StringTrimLeft($crypted, 4)) Return -1 ElseIf RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\" & StringLeft(@ScriptName, StringLen(@ScriptName) - 4), $s_KeyName) = "" Then MsgBox(64, "Error", "You are not allowed to run this program!", 5) Return -2 ElseIf RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\" & StringLeft(@ScriptName, StringLen(@ScriptName) - 4), $s_KeyName) <> _ (StringTrimLeft($crypted, 4)) Then MsgBox(64, "Error", "You are not allowed to run this program on this computer!", 5) Return -3 EndIf Return 1 EndFunc ;==>_runOnlyOnThis oÝ÷ Ù:rدjײ¢êìr¸©·br§r[zËay@Åj«jgz¸¬ºÇbj{)yÈÊØb²«jgz¶òÊ«£ Ӣʫ¦º-yË^uì^¢z- êÏ ÂÊ&i×+%Ûez¥¥êð'!ÊÊ¢¢Ø^
Hope someone will test it and give some feedback!
P.S.: I don't know whether someone did that anyway, before but ...
Edit: Updated version
- Added option runOnlyOnThis Windows( InstallDate) or runOnlyOnThis HardDrive (Serial)
Edit2: 09.06.2006 Changed from code to autoit tags
Thanks!
So long,
Mega
ActivateScript.au3 1.14K
867 downloads
_runOnlyOnThis.au3 2.98K
870 downloads
Edited by th.meger, 09 June 2006 - 08:58 AM.





