I want to prevent my ahk script getting pirated or avoid getting spread to public.
How to make it only work on a specific hdd serial?
AHK allow only to run on specific hdd serial Topic is solved
Re: AHK allow only to run on specific hdd serial
DriveGet
Here is something related-- will be unique to the installation.
https://www.autohotkey.com/boards/viewtopic.php?p=354914#p354914
Code: Select all
DriveGet, sn, Serial, % SubStr(A_WinDir, 1, 2)
MsgBox, 64, Serial number, %sn%
https://www.autohotkey.com/boards/viewtopic.php?p=354914#p354914
Re: AHK allow only to run on specific hdd serial
im really sorry as I am really newbie to this kind of stuff, a good sample of script is the way i learn fast.mikeyww wrote: ↑18 Oct 2020, 19:45DriveGet
Here is something related-- will be unique to the installation.Code: Select all
DriveGet, sn, Serial, % SubStr(A_WinDir, 1, 2) MsgBox, 64, Serial number, %sn%
https://www.autohotkey.com/boards/viewtopic.php?p=354914#p354914
This is my serial "50026B77828278E9"
Can you make a script that it only works on this hdd serial?
Re: AHK allow only to run on specific hdd serial
My previous code showed the volume serial number. This one uses the HDD number.
Code: Select all
If !hddsn("50026B77828278E9") {
MsgBox, 48, Failure, Maybe next time! Aborting.
ExitApp
}
MsgBox, 64, Success, You are good to go!
; Main code goes here
ExitApp
hddsn(sn := "") {
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum
While colSettings[objOSItem]
hddsn := Trim(objOSItem.SerialNumber)
Return sn ? (hddsn = sn) : hddsn
}
Re: AHK allow only to run on specific hdd serial
I get an error" Maybe Next time! Aborting..." even tho im using this pc with the hdd serial " 50026B77828278E9 " .mikeyww wrote: ↑18 Oct 2020, 20:22My previous code showed the volume serial number. This one uses the HDD number.
Code: Select all
If !hddsn("50026B77828278E9") { MsgBox, 48, Failure, Maybe next time! Aborting. ExitApp } MsgBox, 64, Success, You are good to go! ; Main code goes here ExitApp hddsn(sn := "") { objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum While colSettings[objOSItem] hddsn := Trim(objOSItem.SerialNumber) Return sn ? (hddsn = sn) : hddsn }
Re: AHK allow only to run on specific hdd serial
How did you identify your serial number? Does your string contain spaces?
You can run the following to see what it says.
You can run the following to see what it says.
Code: Select all
MsgBox, 64, Your HDD serial number, % hddsn := hddsn()
Clipboard := hddsn
ExitApp
hddsn(sn := "") {
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum
While colSettings[objOSItem]
hddsn := Trim(objOSItem.SerialNumber)
Return sn ? (hddsn = sn) : hddsn
}
Re: AHK allow only to run on specific hdd serial
Now this one works bro, it shows "WCAV93215882"mikeyww wrote: ↑18 Oct 2020, 22:38How did you identify your serial number? Does your string contain spaces?
You can run the following to see what it says.
Code: Select all
MsgBox, 64, Your HDD serial number, % hddsn := hddsn() Clipboard := hddsn ExitApp hddsn(sn := "") { objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum While colSettings[objOSItem] hddsn := Trim(objOSItem.SerialNumber) Return sn ? (hddsn = sn) : hddsn }
Everything is good now, Bless you for bearing with me sir.
Have a great health and day
Thank you
Re: AHK allow only to run on specific hdd serial Topic is solved
This function seems to work more consistently.
Code: Select all
hddsn(sn := "") {
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum
Loop
hddsn := Trim(objOSItem.SerialNumber)
Until !colSettings[objOSItem] || StrLen(hddsn) > 4
Return sn ? (hddsn = sn) : hddsn
}
Re: AHK allow only to run on specific hdd serial
hi, this one is not working, it says "Failure" while this one worksmikeyww wrote: ↑18 Oct 2020, 22:51This function seems to work more consistently.
Code: Select all
hddsn(sn := "") { objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum Loop hddsn := Trim(objOSItem.SerialNumber) Until !colSettings[objOSItem] || StrLen(hddsn) > 4 Return sn ? (hddsn = sn) : hddsn }
Code: Select all
hddsn(sn := "") {
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum
While colSettings[objOSItem]
hddsn := Trim(objOSItem.SerialNumber)
Return sn ? (hddsn = sn) : hddsn
}
Re: AHK allow only to run on specific hdd serial
Interesting. Thanks for the feedback. With the original script, I found different results on different computers, according to the number of drives installed and perhaps other factors. The final version that I provided works on both of my computers, but your experience is different and informative!
Re: AHK allow only to run on specific hdd serial
Return true (1) if SN is correct or false (0) if not
example
Code: Select all
hddsn(sn)
{
for objItem in ComObjGet("winmgmts:").ExecQuery("SELECT * FROM Win32_DiskDrive")
if (InStr(objItem.SerialNumber, sn))
return true
return false
}
Code: Select all
if (hddsn("50026B77828278E9"))
MsgBox % "Success"
else
MsgBox % "Failure"
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: AHK allow only to run on specific hdd serial
Very nice! Thank you, @jNizM!
- FanaticGuru
- Posts: 1906
- Joined: 30 Sep 2013, 22:25
Re: AHK allow only to run on specific hdd serial
Kind of funny that someone that barely understands AHK thinks their script is so great that it would be pirated. And that this "copy protection" can be foiled by any text editor like Notepad.
I guess it would protect your script from someone that does not know how to use Google.
Like two blind people playing "I Spy with my Little Eye".
FG
I guess it would protect your script from someone that does not know how to use Google.
Like two blind people playing "I Spy with my Little Eye".
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: AHK allow only to run on specific hdd serial
The customer shall be the judge!
Re: AHK allow only to run on specific hdd serial
**********************************************mikeyww wrote: ↑18 Oct 2020, 20:22My previous code showed the volume serial number. This one uses the HDD number.
Code: Select all
If !hddsn("50026B77828278E9") { MsgBox, 48, Failure, Maybe next time! Aborting. ExitApp } MsgBox, 64, Success, You are good to go! ; Main code goes here ExitApp hddsn(sn := "") { objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum While colSettings[objOSItem] hddsn := Trim(objOSItem.SerialNumber) Return sn ? (hddsn = sn) : hddsn }
Hello, can you help me, since I see you have a lot of experience, I need to create an App that only runs if the application matches the USB flash serial, can you help me with this. this is the data of my usb.
Kingston DataTraveler 3.0 USB Device
\\.\PHYSICALDRIVE2
EE03DC5154E9
Re: AHK allow only to run on specific hdd serial
Code: Select all
; This script checks a removable drive's serial number for validity
#Requires AutoHotkey v1.1.33
validSN := "EE03DC5154E9"
valid := False
DriveGet driveList, List, REMOVABLE
Loop Parse, % driveList
{ DriveGet sn, Serial, % A_LoopField ":"
If valid := sn = validSN
Break
}
If !valid {
MsgBox 48, Authorization, Authorization is not granted. Aborting.
ExitApp
}
SoundBeep 1500
Re: AHK allow only to run on specific hdd serial
-----------------------------------------------mikeyww wrote: ↑16 Aug 2023, 05:31Code: Select all
; This script checks a removable drive's serial number for validity #Requires AutoHotkey v1.1.33 validSN := "EE03DC5154E9" valid := False DriveGet driveList, List, REMOVABLE Loop Parse, % driveList { DriveGet sn, Serial, % A_LoopField ":" If valid := sn = validSN Break } If !valid { MsgBox 48, Authorization, Authorization is not granted. Aborting. ExitApp } SoundBeep 1500
Hello, Thank you for your prompt response and help, but I have reviewed the code you provided and it does not work. The Serial of my USB is EE03DC5154E9 which in fact is already written in the code, but always when executing the script, whether I put the real serial or a false one, it always sends me the MsgBox 48, Authorization, Authorization is not granted. aborting.
Re: AHK allow only to run on specific hdd serial
You can use the script to display all of the serial numbers found, so that you know what they are.
Who is online
Users browsing this forum: No registered users and 205 guests