Page 1 of 1

Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 02:20
by zanusso
Hello friends of the community, I am very in need of a script that checks the date on a web site before it opens and if possible also does not allow it to open on two computers at the same time.
Is this possible?

Re: Script chacks date and not open on two computers at the same time

Posted: 27 Mar 2018, 05:13
by BoBo
What's the background story/context for that event :?:

Re: Script chacks date and not open on two computers at the same time

Posted: 27 Mar 2018, 05:45
by zanusso
BoBo wrote:What's the background story/context for that event :?:

I want to sell the scripts, however I want to sell for a period of use, for example 3 months, I could put the date that it will end up fixed inside the code, however the script has to check if the date has already passed.

could be up to the date of the computer, but it would be easy to circumvent the script so it would never end the deadline, so I would check in a place where there is no way to circumvent the system.

Re: Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 09:48
by MaxAstro
You aren't going to have much luck with reasonably competent users, since basically anyone who knows what they are doing could decompile the script and remove your timer from it. DRM is hard, especially when you are talking about a program that was never designed to support it.

Re: Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 11:12
by zanusso
MaxAstro wrote:You aren't going to have much luck with reasonably competent users, since basically anyone who knows what they are doing could decompile the script and remove your timer from it. DRM is hard, especially when you are talking about a program that was never designed to support it.


I understand, but would someone like to show an example of how to check the date on an official date and time site?
I will prepare myself for this as neither the best servers in the world are safe from haker and malicious people, but most do not have this knowledge of how to decompile the file.

Re: Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 12:52
by Nightwolf85
Using info I got from this thread: https://autohotkey.com/boards/viewtopic.php?t=6547

I came up with this example which should always give the current date no matter what the user has their computer set to:

Code: Select all

timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, MM/dd/yyyy
MsgBox,, Real Date,  %RealDate%
It saves a temp file and then deletes it, hopefully that won't be an issue.

Re: Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 13:00
by Odlanir
You can try also:

Code: Select all

MsgBox, % GetUTC()

GetUTC() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.timeanddate.com/worldclock/timezone/utc")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, "s).+id=ct class=h1>(.+?)</span>.+?id=ctdat>(.+?)</span>.+", "$1`n$2")
}

Re: Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 20:41
by zanusso
Odlanir wrote:You can try also:

Code: Select all

MsgBox, % GetUTC()

GetUTC() {
    WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
    WebRequest.Open("GET", "http://www.timeanddate.com/worldclock/timezone/utc")
    WebRequest.Send()
    return RegExReplace(WebRequest.ResponseText, "s).+id=ct class=h1>(.+?)</span>.+?id=ctdat>(.+?)</span>.+", "$1`n$2")
}

Thanks for the code, only detail is that I can not create a variable with the same information so I can compare the dates, for example

if the date is greater than 04/27/2018 do not open the program

that noc would be like a one-month license.

could you help me in this?

Re: Script checks date and not open on two computers at the same time

Posted: 27 Mar 2018, 21:02
by zanusso
Nightwolf85 wrote:Using info I got from this thread: https://autohotkey.com/boards/viewtopic.php?t=6547

I came up with this example which should always give the current date no matter what the user has their computer set to:

Code: Select all

timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, MM/dd/yyyy
MsgBox,, Real Date,  %RealDate%
It saves a temp file and then deletes it, hopefully that won't be an issue.

Hello friend, thanks for the help, I wonder if these modifications I made inside the code if they are correct?
the intention is that the program does not open after the date that was placed in the variable (DateExpired)

Code: Select all


DateExpired := 27/03/2018, S
FormatTime, DateExpired, 
timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, dd/MM/yyyy
;MsgBox,, Real Date,  %RealDate%


if (RealDate > DateExpired)
{
	MsgBox, your system has expired
	ExitApp
}
else
	MsgBox, Open the program

Re: Script checks date and not open on two computers at the same time

Posted: 28 Mar 2018, 08:05
by Nightwolf85
zanusso wrote:Hello friend, thanks for the help, I wonder if these modifications I made inside the code if they are correct?
the intention is that the program does not open after the date that was placed in the variable (DateExpired)
I think if you format the time like this it works as you describe?

Code: Select all

DateExpired := 20180327
timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide ; What if this fails? should check it.
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
; This is where I would check if the variable Time has a valid ntp query.
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, yyyyMMdd
;MsgBox,, Real Date,  %RealDate%


if (RealDate > DateExpired)
{
	MsgBox, your system has expired
	ExitApp
}
else
	MsgBox, Open the program
Edit: One issue I can't help with is I don't know what happens if getting the time offset can't connect. You could test and see if the output matches a successful query instead of assuming it does.

Re: Script checks date and not open on two computers at the same time

Posted: 28 Mar 2018, 11:28
by zanusso
Nightwolf85 wrote:
zanusso wrote:Hello friend, thanks for the help, I wonder if these modifications I made inside the code if they are correct?
the intention is that the program does not open after the date that was placed in the variable (DateExpired)
I think if you format the time like this it works as you describe?

Code: Select all

DateExpired := 20180327
timeLoc := A_Temp . "\Time.txt"
RunWait, %ComSpec% /c w32tm /monitor /computers:us.pool.ntp.org > %timeLoc%,, Hide ; What if this fails? should check it.
FileRead, Time, %timeLoc%
Sleep 100
FileDelete, %timeLoc%
; This is where I would check if the variable Time has a valid ntp query.
RegExMatch(Time, "[+-](.*?)\s", Time)
Time := Round(RegExReplace(Time, "[+s]"),0)
RealDate += Time, S
FormatTime, RealDate, %RealDate%, yyyyMMdd
;MsgBox,, Real Date,  %RealDate%


if (RealDate > DateExpired)
{
	MsgBox, your system has expired
	ExitApp
}
else
	MsgBox, Open the program
Edit: One issue I can't help with is I don't know what happens if getting the time offset can't connect. You could test and see if the output matches a successful query instead of assuming it does.


Friend, actually if you do not have a static connection picking up a local time, where it's failing to verify