# Cpu key authentication in a batch file



## smokyGLINT (Apr 24, 2020)

Hello everyone, i am not really a person to seek help when it comes to command prompt batch scripts but im having some trouble. im trying to protect the code i have written and i only want some people to use my application. I have my batch file obfuscated already but i wanted to make a password protection sort of deal that works of say windows product key or a mac address. i thought about having the persons credentials coded inside the application so when they open it, the applications pulls their mac address and then compares it to the credentials coded in the application, if they match then it opens up and they can use the application as they please but if it doesnt match it just closes out of the application. Any help would be greatly appreciated.


----------



## lunarlander (Sep 22, 2007)

Some MAC addresses can be changed in Windows, depends on the network card's driver.

And Windows does not reveal it's product key, Otherwise people will start copying them and passing them around.

Some antivirus programs may take a disliking to obfuscated code. 

The best way to protect your software is to do what MS is doing, require registration of the program to your server.


----------



## smokyGLINT (Apr 24, 2020)

lunarlander said:


> Some MAC addresses can be changed in Windows, depends on the network card's driver.
> 
> And Windows does not reveal it's product key, Otherwise people will start copying them and passing them around.
> 
> ...


well the only problem with that is this is a windows batch file and does not connect to a server of any kind. you can pull the windows product key with this command in a batch file or within command prompt "wmic path softwarelicensingservice get OA3xOriginalProductKey". is there a way i could make an authentication based protection with this command?


----------



## smokyGLINT (Apr 24, 2020)

Nevermind. I found a way to do an authentication with the windows product key. Thx for the help guys. this is the code i got and it works wonderfully, i would imagine it would work with a mac address as well.

@Echo off

:Auth
SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F "tokens=* USEBACKQ" %%F IN (`wmic path softwarelicensingservice get OA3xOriginalProductKey`) DO (
SET var!count!=%%F
SET /a count=!count!+1
)

if not %var2%== productkeyhere goto fail

Echo Authentication Passed. Access Granted
set /p i=Press Enter to Continue}

:fail
echo Invalid Authentication Key. Access is denied.
set /p p=Press Enter to Continue}

cls & goto Auth

endlocal


----------

