baghenamoth Posted December 11, 2006 Share Posted December 11, 2006 Hi Im' trying to read data on an exe file. I have a big pb : when I read the file, some char appears as nul char and I don't know how to interprete this with stringregexp. For exemple in putty.exe: I want to retrieve 0.53b from the line [NUL][NUL][NUL][NUL]PuTTY-Release-0.53b[NUL][NUL] where [NUL] appears as nul char (you can see nul when you load putty.exe or any exe file in scite. is there anyone who knows how to use stringregexp with this special char (or who can explain me the way to read file correctly) ? Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 11, 2006 Share Posted December 11, 2006 (edited) Hi, is this something to get around for getting the version? ;PuTTY-Release- Run("c:\Programme\puTTY\putty.exe", "", @SW_HIDE) WinWaitActive("PuTTY Configuration") WinSetState("PuTTY Configuration", "", @SW_HIDE) ControlClick("PuTTY Configuration", "", 1010, "left", 1) WinWaitActive("About PuTTY") WinSetState("About PuTTY", "", @SW_HIDE) $text = ControlGetText("About PuTTY", "", 1003) ControlClick("About PuTTY", "", 1, "left", 1) ControlClick("PuTTY Configuration", "", 2, "left", 1) MsgBox(0, "", "Version : " & $text) So long, Mega Edited December 11, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
baghenamoth Posted December 11, 2006 Author Share Posted December 11, 2006 (edited) Hi, is this something to get around for getting the version? ;PuTTY-Release- Run("c:\Programme\puTTY\putty.exe", "", @SW_HIDE) WinWaitActive("PuTTY Configuration") WinSetState("PuTTY Configuration", "", @SW_HIDE) ControlClick("PuTTY Configuration", "", 1010, "left", 1) WinWaitActive("About PuTTY") WinSetState("About PuTTY", "", @SW_HIDE) $text = ControlGetText("About PuTTY", "", 1003) ControlClick("About PuTTY", "", 1, "left", 1) ControlClick("PuTTY Configuration", "", 2, "left", 1) MsgBox(0, "", "Version : " & $text) So long, Mega well it's a nice answer which is effectively and quickly giving putty version but I need a completely silent script (which will be run at every user login) Anyway, thx very much for having answered that fast ! I wrote another script which works too, but i takes a least 40 secondes because I'm reading the file char by char (deleting each char which appears as null) Edited December 11, 2006 by baghenamoth Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 11, 2006 Share Posted December 11, 2006 Hi, mabe you can go this way: ConsoleWrite(FileGetSize("c:\Programme\puTTY\putty.exe") & @CRLF) Comparing the size of the exe. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
baghenamoth Posted December 11, 2006 Author Share Posted December 11, 2006 (edited) Hi, mabe you can go this way: ConsoleWrite(FileGetSize("c:\Programme\puTTY\putty.exe") & @CRLF) Comparing the size of the exe. So long, Mega Maybe, it should work for logon script because I just want to verify if the last version is already installed but I'm also making a standard application updater for my company and this one (I know, I am a bit hard ) Anyway I wrote another one which takes 13 secondes (I'm close, I'm gonna find a way...) $binFile = @ProgramFilesDir & "\Putty\putty.exe" $strSearch = "PuTTY-Release-" $Counter = 0 Dim $currText,$Line $i = 0 $Start = 0 While $i < StringLen($strSearch) $File = FileOpen($binFile, 0) If $File = -1 Then Exit $endFile = 0 FileRead ($File, $i) While $endFile = 0 If $Start Then $Char = FileRead($File, 1) If @error = -1 Then Exit If $Char <> "" Then $Line = $Line & $Char Else MsgBox(4096,"Putty Version",$Line) FileClose($File) Exit EndIf Else $currText = FileRead($File, StringLen($strSearch)) If @error = -1 Then $endFile = 1 EndIf If $currText = $strSearch Then $Start = 1 EndIf EndIf WEnd FileClose($File) $i = $i + 1 WEnd Exit Edited December 11, 2006 by baghenamoth Link to comment Share on other sites More sharing options...
baghenamoth Posted December 11, 2006 Author Share Posted December 11, 2006 (edited) finally did it : $Path = @ProgramFilesDir & "\putty\putty.exe" $StringInBin = "50755454592D52656C656173652D" $File = FileOpen($Path,4) If $File = -1 Then ConsoleWrite("error opening file" & @cr) Exit EndIf $Data = FileRead($File,FileGetSize($Path)) If @error Then ConsoleWrite("error reading file" & @cr) Exit EndIf FileClose($File) $Data = String($Data) $Start = StringInStr($Data,$StringInBin) + StringLen($StringInBin) $Data = StringMid($Data,$Start,StringLen($Data)-$Start) $End = StringInStr($Data,"00") $Version = StringMid($Data,0,$End) ConsoleWrite(BinaryToString($Version) & @CR) Func BinaryToString($myBinary) $myString = "" For $i = 1 To StringLen($myBinary) Step 2 $myString = $myString & Chr(Dec(StringMid($myBinary,$i,2))) Next Return $myString EndFunc oÝ÷ Øhmz0ºԮ)àëpyéÝÙ÷öÜ(®H^ë('(uëaz·¢·¢±¦âµ©ç£(§«¢+Ø(ÀÌØíÑôMÑÉ¥¹ ÀÌØíѤ(ÀÌØíMÑÉÐôMÑÉ¥¹%¹MÑÈ ÀÌØíÑ°ÀÌØíMÑÉ¥¹%¹ ¥¸¤¬MÑÉ¥¹1¸ ÀÌØíMÑÉ¥¹%¹ ¥¸¤(ÀÌØíÑôMÑÉ¥¹5¥ ÀÌØíÑ°ÀÌØíMÑÉбMÑÉ¥¹1¸ ÀÌØíѤ´ÀÌØíMÑÉФ(ÀÌØí¹ôMÑÉ¥¹%¹MÑÈ ÀÌØíÑ°ÅÕ½ÐìÀÀÅÕ½Ðì¤(ÀÌØíYÉÍ¥½¸ôMÑÉ¥¹5¥ ÀÌØíÑ°À°ÀÌØí¹¤( Edited December 11, 2006 by baghenamoth 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