Enuma

Download & Check HWID Error

5 posts in this topic

Hi guys,i'm new to AutoIt. And i'm trying to do my best to make my script working just like the way i want,but i don't know why it's not working like the way i want it :(

So here is my problem.

I want to download a .txt file from my host to check HWID is exists on that .txt file or not

If yes,the script continue else the script stopped and delete the file.

I'm using InetGet to download it and want to extract it to another folder (ex : @ScriptDir & "\data\checkhwid.dat")

You can create your own file and check. And when i run it offline,it's still HWID Found....

 

#NoTrayIcon
#include <Array.au3>
#include <FileConstants.au3>
#include <String.au3>
#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $path = (@ScriptDir & '\data\check.dat')
Local $download = InetGet("http://abc.com/check.dat",$path,$INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
InetClose($download)
Local $hFileOpen = FileOpen(@ScriptDir & '\data\check.dat', $FO_OVERWRITE)
If $hFileOpen = -1 Then Exit
FileWrite($hFileOpen, _HWID())
FileClose($hFileOpen)

Local $sHWID = _HWID()
If _GetHWID($sHWID) Then
    MsgBox(64, '', 'HWID Found. Yay!')
    FileDelete($path)
Else
    MsgBox(16, 'Error HWID', 'HWID NOT Found.')
    Exit
EndIf



Func _GetHWID($sHWID)
    Local $aArray = StringSplit(FileRead(@ScriptDir & '\data\check.dat'), @CRLF) ; InetRead('http://mysite.com/test.txt')
    ; _ArrayDisplay($aArray)
    ;Return _ArraySearch($aArray, $sHWID) > -1
    Return _ArraySearch($aArray, $sHWID, 0, 0, 1) > -1 ;case sensitive match
EndFunc   ;==>_GetHWID

Func _HWID()
    Local $sOSDrive = StringLeft(@SystemDir, 3)
    Local $sHWID = '0' & @CPUArch & @KBLayout & DriveGetSerial(@HomeDrive) & StringUpper(DriveGetType($sOSDrive)) & DriveSpaceTotal($sOSDrive)
    $sHWID = StringMid($sHWID, Round(StringLen($sHWID) / 2), Round(StringLen($sHWID) / 2))
    $sHWID = _StringToHex(StringReverse($sHWID))
    Return $sHWID
EndFunc   ;==>_HWID

 

 

 

Share this post


Link to post
Share on other sites



bump

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If I understand the problem correctly, it's always going to find the HWID in your file, because you are writing the HWID into the file before you look for it, right?  Run your script again while offline, but have your data folder where you can see it.  If no file is there it will create it, add the HWID, find it, and then delete it.

FileWrite($hFileOpen, _HWID()) ;This is going to grab your HWID and write it into the local check.dat

 

Edited by MuffinMan
Added info

Share this post


Link to post
Share on other sites
22 hours ago, MuffinMan said:

If I understand the problem correctly, it's always going to find the HWID in your file, because you are writing the HWID into the file before you look for it, right?  Run your script again while offline, but have your data folder where you can see it.  If no file is there it will create it, add the HWID, find it, and then delete it.

FileWrite($hFileOpen, _HWID()) ;This is going to grab your HWID and write it into the local check.dat

 

Thank you for your reply. But i just want the script download the check file on the server and compare it with the HWID of the running machine. If yes. Continue,else exit the script. So i just need to delete the file open and write ?

Share this post


Link to post
Share on other sites

Yeah, comment out the FileWrite and FileClose lines and try it again.

1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now