ur Posted November 17, 2020 Posted November 17, 2020 I will create a form to user to enter two parameters. The first parameter is some restricted data and the second parameter is date to expire. When the user enters the details, the script(compiled exe) should create another exe with the first parameter hard coded and the second parameter(date) set as expiry date to exe. So the target exe generated should not work after the expiry date. Can anyone please suggest how to achieve this.
Nine Posted November 17, 2020 Posted November 17, 2020 Quite easy in fact. Just create a file (FileOpen) and write (FileWrite) the script you want within the file using the variables as needed. Close (FileClose) the file. Then run the au3 compiler (Aut2exe.exe) with the appropriate parameters. Delete (FileDelete) the source script. Run the newly generated .exe. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Multi-Threading Made Easy
ur Posted November 17, 2020 Author Posted November 17, 2020 (edited) Thanks for the reply @Nine But, we want to give direct exe (first one) to end user and he will generate the second exe whenever he want.And also want to set the expiry date also for the second exe as parameter, it should not be usable after that Edited November 17, 2020 by ur
Nine Posted November 17, 2020 Posted November 17, 2020 (edited) It doesn't change what I said. If needed just FileInstall the Aut2Exe.exe file if the user doesn't have the AutoIt on his computer. There is multiple examples in the forum about how to manage expiry date within an autoIt script, just search for it, but the easiest way is compare dates. Edited November 17, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Multi-Threading Made Easy
GokAy Posted November 17, 2020 Posted November 17, 2020 Since @Nine mentioned it, if you are comparing dates and a multi-national company (even a multi-time zone one perhaps), and if the exe will be used by others (lots of if there 😛 ), then account for time zone differences? Depends on how accurate you want to be I guess.
ur Posted November 17, 2020 Author Posted November 17, 2020 Yeah, even that doubt I have. Any suggestion on how to do that. May be by taking the timezone of the target computer where the second exe generated
Developers Jos Posted November 17, 2020 Developers Posted November 17, 2020 Just make a copy of itself and add the variables to the PE Header, like I do with AutoIt3Wrapper and compiled scripts. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
GokAy Posted November 17, 2020 Posted November 17, 2020 (edited) I have written an updater script to be used by Google Drive and used UTC time zones. (Could only test on "my" PC and not extensively). Haven't posted that one yet, but the idea is: ; Set Time Difference Threshold (seconds) Local $iTimeDiffThreshold = 10 ;-------------------------------------------- ; UTC Time Correction Local $tSystemUTC = _Date_Time_GetSystemTime ( ) Local $tSystem = _Date_Time_GetLocalTime ( ) Local $sSystemUTC = _Date_Time_SystemTimeToDateTimeStr($tSystemUTC, 1) Local $sSystem = _Date_Time_SystemTimeToDateTimeStr($tSystem, 1) Local $iUTCDiff = _DateDiff('s', $sSystemUTC, $sSystem) ;-------------------------------------------- ; This part you most likely won't need. I had to do some re-arranging as the datetime formats were not similar. ; Actually scratch the above comment :) You may need to form the string like this, or maybe there is a better way of doing it? Local $aFileTime[6] $aFileTime = FileGetTime($sFolderPath & "\" & $sItemPath,$FT_MODIFIED,$FT_ARRAY) ; File Exists on Client, compare Modified Time ; If Server "Newer" then Add "Updated" to Item, Add "Updated Item" to all parent folders Local $sLocalDate = $aFileTime[0] & "/" & $aFileTime[1] & "/" & $aFileTime[2] & " " & _ $aFileTime[3] & ":" & $aFileTime[4] & ":" & $aFileTime[5] Local $sServerDate = $aCompareThis[$i][17] & "/" & $aCompareThis[$i][18] & "/" & $aCompareThis[$i][19] & " " & _ $aCompareThis[$i][20] & ":" & $aCompareThis[$i][21] & ":" & $aCompareThis[$i][22] ;-------------------------------------------- Local $iTimeDiffSeconds = _DateDiff('s', $sLocalDate, $sServerDate) + $iUTCDiff ; Local - UTC If $iTimeDiffSeconds >= $iTimeDiffThreshold Then ; server is newer ; Do stuff EndIf Also, this one uses modified time rather than created. Edited November 17, 2020 by GokAy Added "my" in bold, changed/added a comment
Cyborg5000 Posted November 17, 2020 Posted November 17, 2020 (edited) Rather check the regions of the users whom you would like to use the script with. Then create the 1st form, get inputs, create another exe Self destruct the 1st exe/form if required, with the first parameter and the second parameter(date) set as expiry date to 2nd exe as per the region/time zones information you have gathered and set in the 2nd exe/else make it also self destruct if required if date & time found. As @Nine said If needed just FileInstall the Aut2Exe.exe file if the user doesn't have the AutoIt on his computer. and further is trial and errors... Edited November 17, 2020 by Cyborg5000
Nine Posted November 17, 2020 Posted November 17, 2020 I am not sure about this issue. If the script is supposed to stop working (lets say) tomorrow at 10pm, why check region/time zones. Unless he wants that his script stops working all over the world at the same exact time ? Maybe OP should give us a better explanation of what he wants to achieve. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Multi-Threading Made Easy
ur Posted November 18, 2020 Author Posted November 18, 2020 (edited) Will the epoch time seconds finished will fix this time zone problem? Because we are checking only seconds here. Like I want to check the date creation time of the exe created and it should not work if the time is more than 2 weeks. Edited November 18, 2020 by ur
GokAy Posted November 18, 2020 Posted November 18, 2020 Hey again, I tested a few things. And here is what I noticed. - "Created" date-time doesn't change when the updated executable name is the same. The behaviour is same even if I delete the exe manually. Maybe Windows needs time to update it, idk. Therefore, I used modified time for the sake of testing. Maybe someone can enlighten us? I am attaching the exe for you to check/test the behaviour, my time zone is UTC + 3 (10800 seconds). Validity of the exe is 2 hours (2 x 60 x 60 seconds) test1 accounts for time zone difference, 10800 is the result of $iUTCDiff for the creator of the exe (in this case mine) test2 just checks exe modified against current time. Same result as test1 for me of course. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=timecheck_test.Exe #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_Run_Au3Stripper=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Date.au3> #include <FileConstants.au3> test1() test2() Func test1() ; UTC Time Zone of Exe Creator (seconds) + Valid seconds Local $iTimeDiffThreshold = 10800 + (2 * 60 * 60) ;(14 * 24 * 60 * 60) ;-------------------------------------------- ; UTC Time Zone for Client Local $tSystemUTC = _Date_Time_GetSystemTime ( ) Local $tSystem = _Date_Time_GetLocalTime ( ) Local $sSystemUTC = _Date_Time_SystemTimeToDateTimeStr($tSystemUTC, 1) Local $sSystem = _Date_Time_SystemTimeToDateTimeStr($tSystem, 1) Local $iUTCDiff = _DateDiff('s', $sSystemUTC, $sSystem) ;-------------------------------------------- Local $aFileTime[6] $aFileTime = FileGetTime(@AutoItExe, $FT_MODIFIED, $FT_ARRAY) Local $sLocalFileTime = $aFileTime[0] & "/" & $aFileTime[1] & "/" & $aFileTime[2] & " " & _ $aFileTime[3] & ":" & $aFileTime[4] & ":" & $aFileTime[5] Local $sLocalTime = @YEAR & "/" & @MON & "/" & @MDAY & " " & _ @HOUR & ":" & @MIN & ":" & @SEC ;-------------------------------------------- Local $iTimeDiffSeconds = _DateDiff('s', $sLocalFileTime, $sLocalTime) + $iUTCDiff - $iTimeDiffThreshold If $iTimeDiffSeconds >= 0 Then msgbox($MB_OK,"Test1","File is not valid (since): " & abs($iTimeDiffSeconds) & " seconds") Else msgbox($MB_OK,"Test1","File is valid (for): " & abs($iTimeDiffSeconds) & " seconds") EndIf EndFunc Func test2() ; Valid seconds Local $iTimeDiffThreshold = 2 * 60 * 60 ;-------------------------------------------- Local $aFileTime[6] $aFileTime = FileGetTime(@AutoItExe, $FT_MODIFIED, $FT_ARRAY) Local $sLocalFileTime = $aFileTime[0] & "/" & $aFileTime[1] & "/" & $aFileTime[2] & " " & _ $aFileTime[3] & ":" & $aFileTime[4] & ":" & $aFileTime[5] Local $sLocalTime = @YEAR & "/" & @MON & "/" & @MDAY & " " & _ @HOUR & ":" & @MIN & ":" & @SEC ;-------------------------------------------- Local $iTimeDiffSeconds = _DateDiff('s', $sLocalFileTime, $sLocalTime) - $iTimeDiffThreshold If $iTimeDiffSeconds >= 0 Then msgbox($MB_OK,"Test2","File is not valid (since): " & abs($iTimeDiffSeconds) & " seconds") Else msgbox($MB_OK,"Test2","File is valid (for): " & abs($iTimeDiffSeconds) & " seconds") EndIf EndFunc timecheck_test.Exe
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now