Enuma Posted July 27, 2016 Share Posted July 27, 2016 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.... expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Enuma Posted July 29, 2016 Author Share Posted July 29, 2016 bump Link to comment Share on other sites More sharing options...
MuffinMan Posted July 29, 2016 Share Posted July 29, 2016 (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 July 29, 2016 by MuffinMan Added info Link to comment Share on other sites More sharing options...
Enuma Posted July 30, 2016 Author Share Posted July 30, 2016 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 ? Link to comment Share on other sites More sharing options...
MuffinMan Posted August 1, 2016 Share Posted August 1, 2016 Yeah, comment out the FileWrite and FileClose lines and try it again. Enuma 1 Link to comment Share on other sites More sharing options...
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